ALICE 1.3  1.3.14
Developer documentation
alice-desktop-1.3.pyw
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: cp1252 -*-
3 #
4 # ADALM1000 alice-desktop 1.3.py(w) (11-29-2022)
5 # For Python version 2.7 or 3.7, Windows OS and Linux OS
6 # With external module pysmu ( libsmu >= 1.0.2 for ADALM1000 )
7 # optional split I/O modes for Rev F hardware supported
8 # Uses new firmware (2.17 or >) that support control of ADC mux configure
9 # Created by D Mercer ()
10 #
11 #
12 import __future__
13 import math
14 import time
15 try:
16  import numpy
17  numpy_found = True
18 except:
19  numpy_found = False
20 #
21 # If runing from source you can un-comment the following to include pyplot
22 try:
23  from matplotlib import pyplot as plt
24  matplot_found = True
25 except:
26  matplot_found = False
27 #
28 import csv
29 import wave
30 import os
31 #import requests
32 import sys
33 import struct
34 import subprocess
35 from time import gmtime, strftime
36 # Check to see if user passed init file name on command line
37 if len(sys.argv) > 1:
38  InitFileName = str(sys.argv[1])
39  print( 'Init file name: ' + InitFileName )
40 else:
41  InitFileName = 'alice_init.ini'
42 
43 if sys.version_info[0] == 2:
44  print ("Python 2.x")
45  import urllib2
46  import tkFont
47  from Tkinter import *
48  from ttk import *
49  from tkFileDialog import askopenfilename
50  from tkFileDialog import asksaveasfilename
51  from tkSimpleDialog import askstring
52  from tkMessageBox import *
53  from tkColorChooser import askcolor
54 if sys.version_info[0] == 3:
55  print ("Python 3.x")
56  import urllib.request, urllib.error, urllib.parse
57  from tkinter.font import *
58  from tkinter import *
59  from tkinter.ttk import *
60  from tkinter.filedialog import askopenfilename
61  from tkinter.filedialog import asksaveasfilename
62  from tkinter.simpledialog import askstring
63  from tkinter.messagebox import *
64  from tkinter.colorchooser import askcolor
65 #
66 import webbrowser
67 try:
68  from pysmu import *
69  pysmu_found = True
70 except:
71  pysmu_found = False
72 #
73 # check which operating system
74 import platform
75 #
76 RevDate = "29 Nov 2022"
77 SWRev = "1.3.14 "
78 Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.14/alice-desktop-1.3-setup.exe'
79 # small bit map of ADI logo for window icon
80 TBicon = """
81 R0lGODlhIAAgAHAAACH5BAEAAAIALAAAAAAgACAAgQAAAP///wAAAAAAAAJJhI+py+0PYwtBWkDp
82 hTnv2XlfEobjUZZnmn4se72vJMtcbYN4ruz44uORgiodsfI4Im++2M5VW81OmBbVULxiRVrUsgsO
83 i8fUAgA7
84 """
85 
86 root=Tk()
87 root.title("ALICE DeskTop " + SWRev + RevDate + ": ALM1000 Oscilloscope")
88 img = PhotoImage(data=TBicon)
89 root.call('wm', 'iconphoto', root._w, '-default', img)
90 print("Windowing System is " + str(root.tk.call('tk', 'windowingsystem')))
91 
92 GRW = 720 # Width of the time grid 720 default
93 GRH = 390 # Height of the time grid 390 default
94 X0L = 55 # Left top X value of time grid
95 Y0T = 25 # Left top Y value of time grid
96 #
97 GRWF = 720 # Width of the spectrum grid 720 default
98 GRHF = 390 # Height of the spectrum grid 390 default
99 X0LF = 45 # Left top X value of spectrum grid
100 Y0TF = 25 # Left top Y value of spectrum grid
101 #
102 GRWBP = 720 # Width of the Bode Plot grid 720 default
103 GRHBP = 390 # Height of the Bode Plot grid 390 default
104 X0LBP = 45 # Left top X value of Bode Plot grid
105 Y0TBP = 25 # Left top Y value of Bode Plot grid
106 #
107 GRWXY = 420 # Width of the XY grid 420 default
108 GRHXY = 390 # Height of the XY grid 390 default
109 X0LXY = 55 # Left top X value of XY grid
110 Y0TXY = 25 # Left top Y value of XY grid
111 #
112 GRWIA = 400 # Width of the grid 400 default
113 GRHIA = 400 # Height of the grid 400 default
114 X0LIA = 37 # Left top X value of grid
115 Y0TIA = 25 # Left top Y value of grid
116 #
117 GRWNqP = 400 # Width of the Nyquist plot grid 400 default
118 GRHNqP = 400 # Height of the grid 400 default
119 X0LNqP = 25 # Left top X value of grid
120 Y0TNqP = 25 # Left top Y value of grid
121 #
122 GRWNiC = 400 # Width of the Nichols plot grid 400 default
123 GRHNiC = 400 # Height of the grid 400 default
124 X0LNiC = 25 # Left top X value of grid
125 Y0TNiC = 25 # Left top Y value of grid
126 #
127 GRWPhA = 400 # Width of the grid 400 default
128 GRHPhA = 400 # Height of the grid 400 default
129 X0LPhA = 37 # Left top X value of grid
130 Y0TPhA = 25 # Left top Y value of grid
131 #
132 RDX0L = 20 # Left top X value of Res Div Schem
133 RDY0T = 20 # Left top Y value of Res Div Schem
134 RDGRW = 530 - ( RDX0L + 230 ) # Width of the Res Div Schem
135 RDGRH = 275 - ( 2 * RDY0T ) # Height of the Res Div Schem
136 R1 = StringVar()
137 R2 = StringVar()
138 Voff = StringVar()
139 VR2 = StringVar()
140 ResDivStatus = IntVar(0)
141 ResDivDisp = IntVar(0)
142 Rint = 1000000.0 # 1 Meg Ohm M1k internal resistor to ground
143 RDeffective = Rint
144 RDGain = 1.0
145 RDOffset = 0.0
146 CHAIleak = 0.0 # 300E-9 # Channel A leakage current
147 CHBIleak = 0.0 # 300E-9 # Channel B leakage current
148 #
149 FontSize = 8
150 BorderSize = 1
151 MouseX = MouseY = -10
152 MouseCAV = MouseCAI = MouseCBV = MouseCBI = MouseMuxA = MouseMuxB = MouseMuxC = MouseMuxD = -10
153 
155  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
156  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
157  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
158 
159  COLORtext = "#ffffff" # 100% white
160  COLORtrigger = "#ff0000" # 100% red
161  COLORsignalband = "#ff0000" # 100% red
162  COLORframes = "#000080" # Color = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
163  COLORcanvas = "#000000" # 100% black
164  COLORgrid = "#808080" # 50% Gray
165  COLORzeroline = "#0000ff" # 100% blue
166  COLORtrace1 = "#00ff00" # 100% green
167  COLORtrace2 = "#ff8000" # 100% orange
168  COLORtrace3 = "#00ffff" # 100% cyan
169  COLORtrace4 = "#ffff00" # 100% yellow
170  COLORtrace5 = "#ff00ff" # 100% magenta
171  COLORtrace6 = "#C80000" # 90% red
172  COLORtrace7 = "#8080ff" # 100% purple
173  COLORtraceR1 = "#008000" # 50% green
174  COLORtraceR2 = "#905000" # 50% orange
175  COLORtraceR3 = "#008080" # 50% cyan
176  COLORtraceR4 = "#808000" # 50% yellow
177  COLORtraceR5 = "#800080" # 50% magenta
178  COLORtraceR6 = "#800000" # 80% red
179  COLORtraceR7 = "#4040a0" # 80% purple
180 
181 #
182 ResetColors()
183 COLORwhite = "#ffffff" # 100% white
184 COLORblack = "#000000" # 100% black
185 ButtonGreen = "#00ff00" # 100% green
186 ButtonRed = "#ff0000" # 100% red
187 GUITheme = "Light"
188 ButtonOrder = 0
189 SBoxarrow = 11
190 Closed = 0
191 ColorMode = IntVar(0)
192 # # Can be Light or Dark or Blue or LtBlue or Custom where:
193 FrameBG = "#d7d7d7" # Background color for frame
194 ButtonText = "#000000" # Button Text color
195 # Widget relief can be RAISED, GROOVE, RIDGE, and FLAT
196 ButRelief = RAISED
197 LabRelief = FLAT
198 FrameRefief = RIDGE
199 LocalLanguage = "English"
200 
201 OnBoardRes = 50.83
202 AD584act = 2.5
203 # Set sample buffer size
204 HoldOff = 0.0
205 LShift = 0
206 BaseSampleRate = 100000
207 AWGSAMPLErate = BaseSampleRate # Sample rate of the AWG channels
208 SAMPLErate = BaseSampleRate # Scope sample rate can be decimated
209 MinSamples = 2000
210 MaxSamples = 200000
211 ETSrecord = 2000
212 AWGRecLength = 32768
213 DISsamples = GRW
214 First_Slow_sweep = 0
215 Slow_Sweep_Limit = 200
216 # set initial trigger conditions
217 TRIGGERlevel = 2.5 # Triggerlevel in volts
218 
219 MathString = "VBuffA[t] + VBuffB[t]"
220 MathUnits = " V"
221 MathXString = "VBuffA[t]"
222 MathXUnits = " V"
223 MathYString = "VBuffB[t]"
224 MathYUnits = " V"
225 UserAString = "MaxV1-VATop"
226 UserALabel = "OverShoot"
227 UserBString = "MinV2-VBBase"
228 UserBLabel = "UnderShoot"
229 MathAxis = "V-A"
230 MathXAxis = "V-A"
231 MathYAxis = "V-B"
232 AWGAMathString = "(VBuffA + VBuffB)/2"
233 AWGBMathString = "(VBuffA + VBuffB)/2"
234 AWGAcsvFile = "examplea.csv"
235 AWGBcsvFile = "exampleb.csv"
236 AWGAwavFile = "examplea.wav"
237 AWGBwavFile = "exampleb.wav"
238 FFTUserWindowString = "numpy.kaiser(SMPfft, 14) * 3"
239 DigFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
240 DigFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
241 AWGFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
242 AWGFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
243 ChaMeasString1 = "DCV1"
244 ChaMeasString2 = "DCI1"
245 ChaMeasString3 = "SV1"
246 ChaMeasString4 = "MaxV1-MinV1"
247 ChaMeasString5 = "MaxI1-MinI1"
248 ChaMeasString6 = "math.sqrt(SV1**2 - DCV1**2)"
249 ChbMeasString1 = "DCV2"
250 ChbMeasString2 = "DCI2"
251 ChbMeasString3 = "SV2"
252 ChbMeasString4 = "MaxV2-MinV2"
253 ChbMeasString5 = "MaxI2-MinI2"
254 ChbMeasString6 = "math.sqrt(SV2**2 - DCV2**2)"
255 ChaLableSrring1 = "CHA-DCV "
256 ChaLableSrring2 = "CHA-DCI "
257 ChaLableSrring3 = "CHA-TRMS "
258 ChaLableSrring4 = "CHA-VP-P "
259 ChaLableSrring5 = "CHA-IP-P "
260 ChaLableSrring6 = "CHA-ACRMS "
261 ChbLableSrring1 = "CHB-DCV "
262 ChbLableSrring2 = "CHB-DCI "
263 ChbLableSrring3 = "CHB-TRMS "
264 ChbLableSrring4 = "CHB-VP-P "
265 ChbLableSrring5 = "CHB-IP-P "
266 ChbLableSrring6 = "CHB-ACRMS "
267 LabelPlotText = IntVar(0)
268 PlotLabelText = "Custom Plot Label"
269 
270 GridWidth = IntVar(0)
271 GridWidth.set(1)
272 TRACEwidth = IntVar(0)
273 TRACEwidth.set(1)
274 TRACEaverage = IntVar(0) # Number of average sweeps for average mode
275 TRACEaverage.set(8)
276 Vdiv = IntVar(0)
277 Vdiv.set(10) # Number of vertical divisions for spectrum / Bode
278 LPFTrigger = IntVar(0) # trigger lpf on/off
279 Trigger_LPF_length = IntVar(0)
280 Trigger_LPF_length.set(10) # Length of Trigger box car LPF in samples
281 HarmonicMarkers = IntVar(0)
282 HarmonicMarkers.set(3)
283 AWGShowAdvanced = IntVar(0)
284 AWGShowAdvanced.set(0)
285 AWG_Amp_Mode = IntVar(0)
286 AWG_Amp_Mode.set(0) # 0 = Min/Max mode, 1 = Amp/Offset
287 AWGA_Ext_Gain = DoubleVar(0)
288 AWGA_Ext_Gain.set(1.0)
289 AWGA_Ext_Offset = DoubleVar(0)
290 AWGA_Ext_Offset.set(0.0)
291 AWGB_Ext_Gain = DoubleVar(0)
292 AWGB_Ext_Gain.set(1.0)
293 AWGB_Ext_Offset = DoubleVar(0)
294 AWGB_Ext_Offset.set(0.0)
295 LockFreq = IntVar(0) # Flag to lock AWG A and AWG B to same frequency
296 AWG_2X = IntVar(0) # selection variable to set AWG DAC channes for 2X samplerate modes
297 Two_X_Sample = IntVar(0) # selection variable to set ADC channes for 2X samplerate mode
298 Two_X_Sample.set(0)
299 ADC_Mux_Mode = IntVar(0) # selection variable to set ADC CHA for voltagr or current 2X samplerate mode
300 ADC_Mux_Mode.set(0)
301 Last_ADC_Mux_Mode = 0
302 Alternate_Sweep_Mode = IntVar(0) # alternate sweeps when in 2X samplerate mode
303 Alternate_Sweep_Mode.set(0)
304 #
305 ChopModeFilter = [0.25, 0.25, 0.25, 0.25] # [0.25, 0.25, 0.25, 0.25]
306 # ChopModeFilter = [0, 1, 2, 3, 4, 3, 2, 1, 0]
307 # ChopModeFilter = numpy.array(ChopModeFilter) / 16
308 Roll_Mode = IntVar(0) # select roll sweep (slow) mode
309 Roll_Mode.set(0)
310 #
311 UnAvgSav = IntVar(0) # Flag to save un trace averaged buffers
312 UnAvgSav.set(0)
313 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
314 ZEROstuffing.set(1)
315 FFTwindow = IntVar(0) # FFT window function variable
316 FFTwindow.set(5) # FFTwindow 0=None (rectangular B=1), 1=Cosine (B=1.24), 2=Triangular non-zero endpoints (B=1.33),
317  # 3=Hann (B=1.5), 4=Blackman (B=1.73), 5=Nuttall (B=2.02), 6=Flat top (B=3.77)
318 RelPhaseCorrection = 15 # Relative Phase error seems to be a random number each time board is powered up
319 RelPhaseCenter = IntVar(0)
320 RelPhaseCenter.set(0) # Center line value for phase plots
321 ImpedanceCenter = IntVar(0)
322 ImpedanceCenter.set(0) # Center line value for impedance plots
323 MultipleBoards = IntVar(0)
324 MultipleBoards.set(0) # Turn on access for multiple m1k boards
325 IgnoreFirmwareCheck = 0
326 EnableScopeOnly = 0
327 EnableXYPlotter = 1
328 EnablePhaseAnalizer = 1
329 EnableSpectrumAnalizer = 1
330 EnableBodePlotter = 1
331 EnableImpedanceAnalizer = 1
332 EnableOhmMeter = 1
333 EnableDigIO = 1
334 EnableCommandInterface = 0
335 EnableMuxMode = 0
336 EnablePIODACMode = 0
337 EnableMinigenMode = 0
338 EnablePmodDA1Mode = 0
339 EnableDigPotMode = 0
340 EnableGenericSerialMode = 0
341 EnableAD5626SerialMode = 0
342 EnableDigitalFilter = 0
343 EnableMeasureScreen = 0
344 EnableETSScreen = 0
345 EnableHSsampling = 0
346 EnableUserEntries = 0
347 AllowFlashFirmware = 0
348 DeBugMode = 0
349 ShowTraceControls = 0
350 # ADC Mux defaults
351 v1_adc_conf = 0x20F1
352 i1_adc_conf = 0x20F7
353 v2_adc_conf = 0x20F7
354 i2_adc_conf = 0x20F1
355 #
356 MouseFocus = 1
357 HistAsPercent = 0
358 ShowBallonHelp = 0
359 contloop = 0
360 discontloop = 0
361 AwgLayout = "Horz"
362 MarkerLoc = 'UL' # can be UL, UR, LL or LR
363 CHA_TC1 = DoubleVar(0)
364 CHA_TC1.set(1)
365 CHA_TC2 = DoubleVar(0)
366 CHA_TC2.set(1)
367 CHB_TC1 = DoubleVar(0)
368 CHB_TC1.set(1)
369 CHB_TC2 = DoubleVar(0)
370 CHB_TC2.set(1)
371 CHA_A1 = DoubleVar(0)
372 CHA_A1.set(1)
373 CHA_A2 = DoubleVar(0)
374 CHA_A2.set(1)
375 CHB_A1 = DoubleVar(0)
376 CHB_A1.set(1)
377 CHB_A2 = DoubleVar(0)
378 CHB_A2.set(1)
379 Auto_ETS_Comp = IntVar(0)
380 ETS_TC1 = DoubleVar(0)
381 ETS_TC1.set(0.18333)
382 ETS_A1 = DoubleVar(0)
383 ETS_A1.set(5.0)
384 ETS_TC2 = DoubleVar(0)
385 ETS_TC2.set(0.03)
386 ETS_A2 = DoubleVar(0)
387 ETS_A2.set(5.0)
388 PhaseOffset1x = 37
389 PhaseOffset2x = 37
390 #('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
391 # 'aqua' built-in native Mac OS X only; Native Mac OS X
392 windowingsystem = root.tk.call('tk', 'windowingsystem')
393 ScreenWidth = root.winfo_screenwidth()
394 ScreenHeight = root.winfo_screenheight()
395 # print(str(ScreenWidth) + "X" + str(ScreenHeight))
396 if (root.tk.call('tk', 'windowingsystem')=='aqua'):
397  Style_String = 'aqua'
398  # On Macs, allow the dock icon to deiconify.
399  root.createcommand('::tk::mac::ReopenApplication', root.deiconify)
400  root.createcommand('::tk::mac::Quit', root.destroy)# Bcloseexit)
401  # On Macs, set up menu bar to be minimal.
402  root.option_add('*tearOff', False)
403  try:
404  if sys.version_info[0] == 2:
405  menubar = tKinter.Menu(root)
406  appmenu = tKinter.Menu(menubar, name='apple')
407  else:
408  menubar = tkinter.Menu(root)
409  appmenu = tkinter.Menu(menubar, name='apple')
410 
411  # menubar = tk.Menu(root)
412  # appmenu = tk.Menu(menubar, name='apple')
413  menubar.add_cascade(menu=appmenu)
414  # appmenu.add_command(label='Exit', command=Bcloseexit)
415  root['menu'] = menubar
416  except:
417  print("Deafult menu bar on Mac non-functional")
418 else:
419  Style_String = 'alt'
420 # Check if there is an alice_init.ini file to read in
421 try:
422  import alice
423  import pathlib
424 # pathlib only available as standard in Python 3.4 and higher. For Python 2.7 must manually install package
425  path = pathlib.Path(alice.__file__).parent.absolute()
426  filename = os.path.join(path, "resources", InitFileName) # "alice_init.ini")
427  InitFile = open(filename)
428  for line in InitFile:
429  try:
430  exec( line.rstrip(), globals(), globals())
431  #exec( line.rstrip() )
432  except:
433  print("Skiping " + line.rstrip())
434  InitFile.close()
435 except:
436  try:
437  InitFile = open(InitFileName) # "alice_init.ini"
438  for line in InitFile:
439  try:
440  exec( line.rstrip(), globals(), globals())
441  #exec( line.rstrip() )
442  except:
443  print("Skiping " + line.rstrip())
444  InitFile.close()
445  except:
446  print( "No Init File Read. " + InitFileName + " Not Found")
447 #
448 XOLXY = X0L = FontSize * 7
449 XOLF = XOLBP = XOLIA = int(FontSize * 4.625)
450 XOLNqP = XOLNiC = int(FontSize * 3.125)
451 root.style = Style()
452 try:
453  root.style.theme_use(Style_String)
454 except:
455  root.style.theme_use('default')
456 if MouseFocus == 1:
457  root.tk_focusFollowsMouse()
458 #
459 DevID = "m1k"
460 #
461 if sys.version_info[0] == 2:
462  default_font = tkFont.nametofont("TkDefaultFont")
463 if sys.version_info[0] == 3:
464  default_font = tkinter.font.nametofont("TkDefaultFont")
465 try:
466  default_font.config(size=FontSize) # or .configure ?
467 except:
468  print("Warning! Default Font Size was not set")
469 #
470 
471 CHvpdiv = (0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0)
472 
473 CHipdiv = (0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
474 
475 SAMagdiv = ("10nV", "100nV", "1uV", "10uV", "100uV", "1mV", "10mV", "0.1", "1.0", "10.0")
476 
477 TMpdiv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
478 ResScalediv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000)
479 SampRateList = (1024, 2048, 4096, 8194, 16393, 32787, 65574, 93023, 93385, 93750, 94118,
480  96385, 96774, 97166, 97561, 97959, 98361, 98765, 99174, 99585, 100000)
481 NoiseList =[ "None", "Uniform", "Gaussian"]
482 TIMEdiv = 0.5
483 RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
484 
485 
486 AWGAAmplvalue = 0.0
487 AWGAOffsetvalue = 0.0
488 AWGAFreqvalue = 0.0
489 AWGAPhasevalue = 0
490 AWGAdelayvalue = 0
491 AWGADutyCyclevalue = 50
492 AWGAWave = 'dc'
493 AWGBAmplvalue = 0.0
494 AWGBOffsetvalue = 0.0
495 AWGBFreqvalue = 0.0
496 AWGBPhasevalue = 0
497 AWGBdelayvalue = 0
498 AWGBDutyCyclevalue = 50
499 AWGBWave = 'dc'
500 AWGACycles = 1
501 AWGBCycles = 1
502 AWGABurstDelay = 0
503 AWGBBurstDelay = 0
504 Reset_Freq = 300
505 MeasGateLeft = 0.0
506 MeasGateRight = 0.0 # in mSec
507 MeasGateNum = 0
508 MeasGateStatus = IntVar(0)
509 MeasGateStatus.set(0)
510 #
511 DCV1 = DCV2 = MinV1 = MaxV1 = MinV2 = MaxV2 = MidV1 = PPV1 = MidV2 = PPV2 = SV1 = SI1 = 0
512 
513 DCVMuxA = MinVMuxA = MaxVMuxA = MidVMuxA = PPVMuxA = SVMuxA = 0
514 DCVMuxB = MinVMuxB = MaxVMuxB = MidVMuxB = PPVMuxB = SVMuxB = 0
515 DCVMuxC = MinVMuxC = MaxVMuxC = MidVMuxC = PPVMuxC = SVMuxC = 0
516 DCVMuxD = MinVMuxD = MaxVMuxD = MidVMuxD = PPVMuxD = SVMuxD = 0
517 PeakVA = PeakVB = PeakVAB = PeakIA = PeakIB = PeakIAB = 0.0
518 PeakVMA = PeakVMB = PeakVMC = PeakVMD = 0.0
519 PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
520 PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = PeakfreqIAB = 0.0
521 PeakphaseVA = PeakphaseVB = PeakphaseIA = PeakphaseIB = PeakphaseVAB = PeakphaseIAB = 0.0
522 CHADCy = CHBDCy = 0
523 DCI1 = DCI2 = MinI1 = MaxI1 = MinI2 = MaxI2 = MidI1 = PPI1 = MidI2 = PPI2 = SV2 = SI2 = 0
524 CHAperiod = CHAfreq = CHBperiod = CHBfreq = 0
525 # Calibration coefficients
526 CHAVGain = CHBVGain = 1.0
527 CHAVOffset = CHBVOffset = 0.0
528 # Initialisation of general variables
529 CHAOffset = CHBOffset = CHBAOffset = CHBBOffset = CHBCOffset = CHBDOffset = 2.5
530 CHAIOffset = CHBIOffset = InOffA = InGainA = InOffB = InGainB = 0.0
531 # Other global variables required in various routines
532 CANVASwidth = GRW + 2 * X0L # The canvas width
533 CANVASheight = GRH + Y0T + (FontSize * 7) # The canvas height
534 
535 ADsignal1 = [] # Ain signal array channel A and B
536 VBuffA = []
537 VBuffB = []
538 IBuffA = []
539 IBuffB = []
540 VBuffMA = []
541 VBuffMB = []
542 VBuffMC = []
543 VBuffMD = []
544 VmemoryMuxA = []
545 VmemoryMuxB = []
546 VmemoryMuxC = []
547 VmemoryMuxD = []
548 #
549 VUnAvgA = []
550 VUnAvgB = []
551 IUnAvgA = []
552 IUnAvgB = []
553 #
554 DBuff0 = []
555 DBuff1 = []
556 DBuff2 = []
557 DBuff3 = []
558 #
559 VAresult = []
560 VBresult = []
561 IAresult = []
562 IBresult = []
563 IABresult = []
564 PhaseIA = []
565 PhaseIB = []
566 PhaseIAB = []
567 PhaseVA = []
568 PhaseVB = []
569 DFiltACoef = [1]
570 DFiltBCoef = [1]
571 DigFiltA = IntVar(0)
572 DigFiltA.set(0)
573 DigFiltABoxCar = IntVar(0)
574 DigFiltBBoxCar = IntVar(0)
575 DigDeSkewVA = IntVar(0)
576 DigDeSkewVB = IntVar(0)
577 DigDeSkewIA = IntVar(0)
578 DigDeSkewIB = IntVar(0)
579 DigFiltB = IntVar(0)
580 DigFiltB.set(0)
581 DigBuffA = IntVar(0)
582 DigBuffB = IntVar(0)
583 DigBuffA.set(0)
584 DigBuffB.set(0)
585 AWGFiltA = IntVar(0)
586 AWGFiltB = IntVar(0)
587 AWGFiltABoxCar = IntVar(0)
588 AWGFiltBBoxCar = IntVar(0)
589 AWGFiltACoef = [1]
590 AWGFiltBCoef = [1]
591 VFilterA = {}
592 VFilterB = {}
593 SampleRateStatus = IntVar(0)
594 ETSStatus = IntVar(0)
595 ETSDisp = IntVar(0)
596 ETSDir = IntVar(0)
597 #
598 AWGAwaveform = []
599 AWGA2X = [] # array for odd numbers samples when in 2x sample rate
600 AWGBwaveform = []
601 AWGB2X = [] # array for odd numbers samples when in 2x sample rate
602 VmemoryA = numpy.ones(1) # The memory for averaging
603 VmemoryB = numpy.ones(1)
604 ImemoryA = numpy.ones(1) # The memory for averaging
605 ImemoryB = numpy.ones(1)
606 TRACEresetTime = True # True for first new trace, false for averageing
607 TRACEresetFreq = True # True for first new trace, false for averageing
608 AWGScreenStatus = IntVar(0)
609 
610 T1Vline = [] # Voltage Trace line channel A
611 T2Vline = [] # Voltage Trace line channel B
612 T1Iline = [] # Current Trace line channel A
613 T2Iline = [] # Current Trace line channel B
614 TMAVline = [] # Voltage Trace line MUX channel A
615 TMBVline = [] # Voltage Trace line MUX channel B
616 TMCVline = [] # Voltage Trace line MUX channel C
617 TMDVline = [] # Voltage Trace line MUX channel D
618 TMARline = [] # V reference Trace line MUX channel A
619 TMBRline = [] # V reference Trace line MUX channel B
620 TMCRline = [] # V reference line MUX channel C
621 TMDRline = [] # V reference line MUX channel D
622 XYlineVA = [] # XY Trace lines
623 XYlineVB = []
624 XYlineIA = []
625 XYlineIB = []
626 XYlineM = []
627 XYlineMX = []
628 XYlineMY = []
629 XYRlineVA = [] # XY reference trace lines
630 XYRlineVB = []
631 XYRlineIA = []
632 XYRlineIB = []
633 XYRlineM = []
634 XYRlineMX = []
635 XYRlineMY = []
636 Tmathline = [] # Time Math trace line
637 TMXline = [] # Time X math Trace line
638 TMYline = [] # Time Y math Trace line
639 T1VRline = [] # V reference Trace line channel A
640 T2VRline = [] # V reference Trace line channel B
641 T1IRline = [] # I reference Trace line channel A
642 T2IRline = [] # I reference Trace line channel B
643 TMRline = [] # Math reference Trace line
644 D0line = [] # Digital input 0 Trace line
645 D1line = [] # Digital input 1 Trace line
646 D2line = [] # Digital input 2 Trace line
647 D3line = [] # Digital input 3 Trace line
648 Triggerline = [] # Triggerline
649 Triggersymbol = [] # Trigger symbol
650 #
651 SHOWsamples = 4000 # Number of samples on the screen
652 SCstart = 0 # Start sample of the trace
653 HozPoss = 0.0
654 Is_Triggered = 0
655 #
656 TRACES = 1 # Number of traces 1 or 2
657 TRACESread = 0 # Number of traces that have been read from ALM
658 ScreenTrefresh = IntVar(0)
659 ScreenXYrefresh = IntVar(0)
660 #
661 NSteps = IntVar(0) # number of frequency sweep steps
662 NSteps.set(128)
663 LoopNum = IntVar(0)
664 LoopNum.set(1)
665 LastWindow = -1
666 LastSMPfft = 0
667 CurrentFreqX = X0LBP + 14
668 FBins = numpy.linspace(0, 50000, num=16384)
669 FStep = numpy.linspace(0, 16384, num=NSteps.get())
670 FSweepMode = IntVar(0)
671 FSweepCont = IntVar(0)
672 FStepSync = IntVar(0)
673 FSweepSync = IntVar(0)
674 ShowCA_VdB = IntVar(0) # curves to display variables
675 ShowCA_P = IntVar(0)
676 ShowCB_VdB = IntVar(0)
677 ShowCB_P = IntVar(0)
678 ShowMarkerBP = IntVar(0)
679 ShowCA_RdB = IntVar(0)
680 ShowCA_RP = IntVar(0)
681 ShowCB_RdB = IntVar(0)
682 ShowCB_RP = IntVar(0)
683 ShowMathBP = IntVar(0)
684 ShowRMathBP = IntVar(0)
685 SingleShotSA = IntVar(0) # variable for Single Shot sweeps
686 FSweepAdB = []
687 FSweepBdB = []
688 FSweepAPh = []
689 FSweepBPh = []
690 NSweepSeriesR = []
691 NSweepSeriesX = []
692 NSweepSeriesMag = [] # in ohms
693 NSweepSeriesAng = [] # in degrees
694 NSweepParallelR = []
695 NSweepParallelC = []
696 NSweepParallelL = []
697 NSweepSeriesC = []
698 NSweepSeriesL = []
699 NetworkScreenStatus = IntVar(0)
700 BDSweepFile = IntVar(0)
701 FileSweepFreq = []
702 FileSweepAmpl = []
703 #
704 MarkerNum = MarkerFreqNum = 0
705 ShowTCur = IntVar(0)
706 ShowVCur = IntVar(0)
707 TCursor = VCursor = 0
708 ShowXCur = IntVar(0)
709 ShowYCur = IntVar(0)
710 XCursor = YCursor = 0
711 ShowFCur = IntVar(0)
712 ShowdBCur = IntVar(0)
713 FCursor = dBCursor = 0
714 ShowBPCur = IntVar(0)
715 ShowBdBCur = IntVar(0)
716 BPCursor = BdBCursor = 0
717 RUNstatus = IntVar(0) # 0 stopped, 1 start, 2 running, 3 stop and restart, 4 stop
718 PowerStatus = 1
719 TRIGGERsample = 0 # AD sample trigger point
720 DX = 0 # interpolated trigger point
721 
722 DBdivlist = [1, 2, 3, 5, 10, 15, 20] # dB per division
723 DBdivindex = IntVar(0) # 10 dB/div as initial value
724 DBdivindex.set(4)
725 DBlevel = IntVar(0) # Reference level
726 DBlevel.set(0)
727 DBdivindexBP = IntVar(0) # 10 dB/div as initial value
728 DBdivindexBP.set(4)
729 DBlevelBP = IntVar(0) # Reference level
730 DBlevelBP.set(0)
731 hldn = 0
732 SpectrumScreenStatus = IntVar(0)
733 SmoothCurvesSA = IntVar(0)
734 SmoothCurvesBP = IntVar(0)
735 CutDC = IntVar(0)
736 IAScreenStatus = IntVar(0)
737 NqPScreenStatus = IntVar(0)
738 NqPDisp = IntVar(0)
739 NiCScreenStatus = IntVar(0)
740 NiCDisp = IntVar(0)
741 ImpedanceMagnitude = 0.0 # in ohms
742 ImpedanceAngle = 0.0 # in degrees
743 ImpedanceRseries = 0.0 # in ohms
744 ImpedanceXseries = 0.0 # in ohms
745 Show_Rseries = IntVar(0)
746 Show_Xseries = IntVar(0)
747 Show_Magnitude = IntVar(0)
748 Show_Angle = IntVar(0)
749 Show_RseriesRef = IntVar(0)
750 Show_XseriesRef = IntVar(0)
751 Show_MagnitudeRef = IntVar(0)
752 Show_AngleRef = IntVar(0)
753 
754 TIARline = []
755 TIAXline = []
756 TIAMagline = []
757 TIAAngline = []
758 TIAMline = []
759 TIAMRline = []
760 RefIARline = []
761 RefIAXline = []
762 RefIAMagline = []
763 RefIAAngline = []
764 IASource = IntVar(0)
765 IAGridType = IntVar(0)
766 
767 DisplaySeries = IntVar(0)
768 IA_Ext_Conf = IntVar(0)
769 IASweepSaved = IntVar(0)
770 OverRangeFlagA = 0
771 OverRangeFlagB = 0
772 PeakdbA = 10
773 PeakdbB = 10
774 PeakRelPhase = 0.0
775 PeakfreqA = 100
776 PeakfreqB = 1000
777 OhmStatus = IntVar(0)
778 OhmRunStatus = IntVar(0)
779 FFTbandwidth = 0 # The FFT bandwidth
780 FFTBuffA = [] # Clear the FFTBuff array for trace A
781 FFTBuffB = [] # Clear the FFTBuff array for trace B
782 FFTresultA = [] # FFT result CHA
783 PhaseA = []
784 FFTresultB = [] # FFT result CHB
785 PhaseB = []
786 FFTresultAB = []
787 FFTwindowname = "--" # The FFT window name
788 FFTmemoryA = numpy.ones(1) # The memory for averaging
789 PhaseMemoryA = numpy.ones(1)
790 FFTmemoryB = numpy.ones(1) # The memory for averaging
791 PhaseMemoryB = numpy.ones(1)
792 SMPfftpwrTwo = IntVar(0) # The power of two of SMPfft
793 SMPfftpwrTwo.set(11)
794 SMPfft = 2 ** SMPfftpwrTwo.get() # Initialize
795 Two28 = 268435456
796 FFTwindowshape = numpy.ones(SMPfft) # The FFT window curve
797 
798 T1Fline = [] # Frequency Trace line channel A
799 T2Fline = [] # Frequency Trace line channel B
800 T1Pline = [] # Phase angle Trace line channel A - B
801 T2Pline = [] # Phase angle Trace line channel B - A
802 T1FRline = [] # F reference Trace line channel A
803 T2FRline = [] # F reference Trace line channel B
804 T1PRline = [] # Phase reference Trace line channel A - B
805 T2PRline = [] # Phase reference Trace line channel B - A
806 TFMline = [] # Frequency Math Trace
807 TFRMline = [] # Frequency reference Math Trace
808 FreqTraceMode = IntVar(0) # 1 normal mode, 2 max hold mode, 3 average mode
809 FreqTraceMode.set(1)
810 
811 TAFline = [] # Bode Freq Trace line channel A
812 TBFline = [] # Bode Freq Trace line channel B
813 TAPline = [] # Bode Phase angle Trace line channel A - B
814 TBPline = [] # Bode Phase angle Trace line channel B - A
815 TAFRline = [] # Bode F reference Trace line channel A
816 TBFRline = [] # Bode F reference Trace line channel B
817 TAPRline = [] # Bode Phase reference Trace line channel A - B
818 TBPRline = [] # Bode Phase reference Trace line channel B - A
819 TBPMline = [] # Bode Frequency Math Trace
820 TBPRMline = [] # Bode Frequency reference Math Trace
821 #
822 MinSamplesSA = 64
823 MaxSamplesSA = 65536
824 #
825 MathScreenStatus = IntVar(0)
826 ColorScreenStatus = IntVar(0)
827 XYScreenStatus = IntVar(0)
828 Xsignal = IntVar(0) # Signal for X axis variable
829 Xsignal.set(1)
830 YsignalVA = IntVar(0) # Signal for Y axis variable
831 YsignalVB = IntVar(0)
832 YsignalIA = IntVar(0)
833 YsignalIB = IntVar(0)
834 YsignalM = IntVar(0)
835 YsignalMX = IntVar(0)
836 YsignalMY = IntVar(0)
837 YsignalVB.set(1)
838 XYRefAV = IntVar(0) # show reference XY traces
839 XYRefBV = IntVar(0)
840 XYRefAI = IntVar(0)
841 XYRefBI = IntVar(0)
842 XYRefM = IntVar(0)
843 XYRefMX = IntVar(0)
844 XYRefMY = IntVar(0)
845 # show Analog Input Mux Variables
846 Show_CBA = IntVar(0)
847 Show_CBB = IntVar(0)
848 Show_CBC = IntVar(0)
849 Show_CBD = IntVar(0)
850 ShowRMA = IntVar(0)
851 ShowRMB = IntVar(0)
852 ShowRMC = IntVar(0)
853 ShowRMD = IntVar(0)
854 D0 = IntVar(0)
855 D1 = IntVar(0)
856 D2 = IntVar(0)
857 D3 = IntVar(0)
858 D4 = IntVar(0)
859 D5 = IntVar(0)
860 D6 = IntVar(0)
861 D7 = IntVar(0)
862 D0.set(0x50)
863 D1.set(0x50)
864 D2.set(0x50)
865 D3.set(0x50)
866 D4.set(0x50)
867 D5.set(0x50)
868 D6.set(0x50)
869 D7.set(0x50)
870 PIO_0 = 28
871 PIO_1 = 29
872 PIO_2 = 47
873 PIO_3 = 3
874 PIO_4 = 4
875 PIO_5 = 5
876 PIO_6 = 6
877 PIO_7 = 7
878 #
879 SCLKPort = IntVar(0)
880 SDATAPort = IntVar(0)
881 SLATCHPort = IntVar(0)
882 
883 
884 hipulse = """
885 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
886 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
887 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
888 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
889 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
890 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
891 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
892 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
893 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
894 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
895 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
896 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
897 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
898 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
899 sKDBgw8AKFzIsKFChA4jMoQoUSJFAAgHLryYUeDGgx8zhiw4EuRDkxg7ltR4UmRLki9RclQZk2VK
900 lzdh5pTJE+dMnz1/6uyYsKZHowRXHt1pcGREohUbQo2qNKlDolgFBgQAOw==
901 """
902 hipulseimg = PhotoImage(data=hipulse)
903 
904 lowpulse = """
905 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
906 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
907 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
908 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
909 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
910 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
911 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
912 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
913 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
914 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
915 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
916 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
917 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
918 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
919 sKBBggASKgRwEOHChwsbDoRIkaHEBxQdWpSosGHHix8NhvSYkORGkyhBljw4kuVKkS9TwjzpkubE
920 mDVl6tR4ESPOmzYLtgTac6hAozxzqgzqkynRmhUhmoz6cCpVpD0vBgQAOw==
921 """
922 lowpulseimg = PhotoImage(data=lowpulse)
923 
924 class CreateToolTip(object):
925 
926  def __init__(self, widget, text='widget info'):
927  self.waittime = 500 #miliseconds
928  self.wraplength = 100 #pixels
929  self.widget = widget
930  self.text = text
931  self.widget.bind("<Enter>", self.enter)
932  self.widget.bind("<Leave>", self.leave)
933  self.widget.bind("<ButtonPress>", self.leave)
934  self.id = None
935  self.tw = None
936 
937  def enter(self, event=None):
938  self.schedule()
939 
940  def leave(self, event=None):
941  self.unschedule()
942  self.hidetip()
943 
944  def schedule(self):
945  self.unschedule()
946  self.id = self.widget.after(self.waittime, self.showtip)
947 
948  def unschedule(self):
949  id = self.id
950  self.id = None
951  if id:
952  self.widget.after_cancel(id)
953 
954  def showtip(self, event=None):
955  x = y = 0
956  x, y, cx, cy = self.widget.bbox("insert")
957  x += self.widget.winfo_rootx() + 25
958  y += self.widget.winfo_rooty() + 20
959  # creates a toplevel window
960  self.tw = Toplevel(self.widget)
961  # Leaves only the label and removes the app window
962  self.tw.wm_overrideredirect(True)
963  self.tw.wm_geometry("+%d+%d" % (x, y))
964  label = Label(self.tw, text=self.text, justify='left',
965  background="#ffffe0", foreground="#000000",
966  relief='solid', borderwidth=1,
967  wraplength = self.wraplength)
968  label.pack(ipadx=1)
969 
970  def hidetip(self):
971  tw = self.tw
972  self.tw= None
973  if tw:
974  tw.destroy()
975 
976  def configure(self, text):
977  self.text = text
978 #
979 # =========== Start widgets routines =============================
980 
982 def BSaveConfig(filename):
983  global TgInput, TgEdge, ManualTrigger, SingleShot, AutoLevel, SingleShotSA
984  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
985  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
986  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
987  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
988  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
989  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
990  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
991  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
992  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
993  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
994  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
995  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
996  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
997  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
998  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
999  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1000  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase
1001  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1002  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1003  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1004  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, DacScreenStatus, DigScreenStatus
1005  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1006  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1007  global TimeDisp, XYDisp, FreqDisp, IADisp, XYScreenStatus, IAScreenStatus, SpectrumScreenStatus
1008  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry, AWGAPhaseDelay, AWGBPhaseDelay
1009  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasDelay
1010  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb, ChopMuxMode, ChopTrig, DualMuxMode
1011  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
1012  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, HozPossentry
1013  global SmoothCurvesBP, bodewindow, AWG_Amp_Mode, ColorMode
1014  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp
1015  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP
1016  global BPSweepMode, BPSweepCont, BodeScreenStatus, RevDate, SweepStepBodeEntry
1017  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
1018  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1019  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1020  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1021  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1022  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1023  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1024  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1025  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1026  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1027  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter, NetworkScreenStatus
1028  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1029  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1030  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1031  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAcsvFile, AWGBcsvFile
1032  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGAwavFile, AWGBwavFile
1033  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1034  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
1035  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
1036  global DigFiltStatus, DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
1037  global phawindow, PhAca, PhAScreenStatus, PhADisp
1038  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, BoardStatus, boardwindow, BrdSel
1039  global VScale, IScale, RefphEntry, EnableScopeOnly, Roll_Mode
1040  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, iapbt_btn
1041  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1042  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1043  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1044  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1045  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
1046  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
1047  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
1048  # open Config file for Write?
1049  try:
1050  ConfgFile = open(filename, "w")
1051  except: # didn't work? then just return
1052  return
1053  # Save Window placements
1054  ConfgFile.write("root.geometry('+" + str(root.winfo_x()) + '+' + str(root.winfo_y()) + "')\n")
1055  if EnableScopeOnly == 0:
1056  ConfgFile.write("awgwindow.geometry('+" + str(awgwindow.winfo_x()) + '+' + str(awgwindow.winfo_y()) + "')\n")
1057  ConfgFile.write('GRW = ' + str(GRW) + '\n')
1058  ConfgFile.write('GRH = ' + str(GRH) + '\n')
1059  ConfgFile.write('ColorMode.set(' + str(ColorMode.get()) + ')\n')
1060  # Windows configuration
1061  ConfgFile.write('MathString = "' + MathString + '"\n')
1062  ConfgFile.write('MathUnits = "' + MathUnits + '"\n')
1063  ConfgFile.write('MathAxis = "' + MathAxis + '"\n')
1064  ConfgFile.write('MathXString = "' + MathXString + '"\n')
1065  ConfgFile.write('MathXUnits = "' + MathXUnits + '"\n')
1066  ConfgFile.write('MathXAxis = "' + MathXAxis + '"\n')
1067  ConfgFile.write('MathYString = "' + MathYString + '"\n')
1068  ConfgFile.write('MathYUnits = "' + MathYUnits + '"\n')
1069  ConfgFile.write('MathYAxis = "' + MathYAxis + '"\n')
1070  # Save Color Def
1071  ConfgFile.write('COLORtext = "' + COLORtext + '"\n')
1072  ConfgFile.write('COLORcanvas = "' + COLORcanvas + '"\n')
1073  ConfgFile.write('COLORtrigger = "' + COLORtrigger + '"\n')
1074  ConfgFile.write('COLORsignalband = "' + COLORsignalband + '"\n')
1075  ConfgFile.write('COLORframes = "' + COLORframes + '"\n')
1076  ConfgFile.write('COLORgrid = "' + COLORgrid + '"\n')
1077  ConfgFile.write('COLORtrace1 = "' + COLORtrace1 + '"\n')
1078  ConfgFile.write('COLORtraceR1 = "' + COLORtraceR1 + '"\n')
1079  ConfgFile.write('COLORtrace2 = "' + COLORtrace2 + '"\n')
1080  ConfgFile.write('COLORtraceR2 = "' + COLORtraceR2 + '"\n')
1081  ConfgFile.write('COLORtrace3 = "' + COLORtrace3 + '"\n')
1082  ConfgFile.write('COLORtraceR3 = "' + COLORtraceR3 + '"\n')
1083  ConfgFile.write('COLORtrace4 = "' + COLORtrace4 + '"\n')
1084  ConfgFile.write('COLORtraceR4 = "' + COLORtraceR4 + '"\n')
1085  ConfgFile.write('COLORtrace5 = "' + COLORtrace5 + '"\n')
1086  ConfgFile.write('COLORtraceR5 = "' + COLORtraceR5 + '"\n')
1087  ConfgFile.write('COLORtrace6 = "' + COLORtrace6 + '"\n')
1088  ConfgFile.write('COLORtraceR6 = "' + COLORtraceR6 + '"\n')
1089  ConfgFile.write('COLORtrace7 = "' + COLORtrace7 + '"\n')
1090  ConfgFile.write('COLORtraceR7 = "' + COLORtraceR7 + '"\n')
1091  #
1092  if BoardStatus.get() > 0:
1093  ConfgFile.write('MakeBoardScreen()\n')
1094  ConfgFile.write("boardwindow.geometry('+" + str(boardwindow.winfo_x()) + '+' + str(boardwindow.winfo_y()) + "')\n")
1095  ConfgFile.write('BrdSel.set(' + str(BrdSel.get()) + ')\n')
1096  ConfgFile.write('SelectBoard()\n')
1097  else:
1098  ConfgFile.write('DestroyBoardScreen()\n')
1099  if MathScreenStatus.get() > 0:
1100  ConfgFile.write('NewEnterMathControls()\n')
1101  ConfgFile.write("MathWindow.geometry('+" + str(MathWindow.winfo_x()) + '+' + str(MathWindow.winfo_y()) + "')\n")
1102  else:
1103  ConfgFile.write('DestroyMathScreen()\n')
1104  if XYScreenStatus.get() > 0:
1105  ConfgFile.write('GRWXY = ' + str(GRWXY) + '\n')
1106  ConfgFile.write('GRHXY = ' + str(GRHXY) + '\n')
1107  ConfgFile.write('MakeXYWindow()\n')
1108  ConfgFile.write("xywindow.geometry('+" + str(xywindow.winfo_x()) + '+' + str(xywindow.winfo_y()) + "')\n")
1109  ConfgFile.write('CHAsbxy.delete(0,END)\n')
1110  ConfgFile.write('CHAsbxy.insert(0, ' + CHAsbxy.get() + ')\n')
1111  ConfgFile.write('CHAIsbxy.delete(0,END)\n')
1112  ConfgFile.write('CHAIsbxy.insert(0, ' + CHAIsbxy.get() + ')\n')
1113  ConfgFile.write('CHAVPosEntryxy.delete(0,END)\n')
1114  ConfgFile.write('CHAVPosEntryxy.insert(4, ' + CHAVPosEntryxy.get() + ')\n')
1115  ConfgFile.write('CHAIPosEntryxy.delete(0,END)\n')
1116  ConfgFile.write('CHAIPosEntryxy.insert(4, ' + CHAIPosEntryxy.get() + ')\n')
1117  ConfgFile.write('CHBsbxy.delete(0,END)\n')
1118  ConfgFile.write('CHBsbxy.insert(0, ' + CHBsbxy.get() + ')\n')
1119  ConfgFile.write('CHBIsbxy.delete(0,END)\n')
1120  ConfgFile.write('CHBIsbxy.insert(0, ' + CHBIsbxy.get() + ')\n')
1121  ConfgFile.write('CHBVPosEntryxy.delete(0,END)\n')
1122  ConfgFile.write('CHBVPosEntryxy.insert(4, ' + CHBVPosEntryxy.get() + ')\n')
1123  ConfgFile.write('CHBIPosEntryxy.delete(0,END)\n')
1124  ConfgFile.write('CHBIPosEntryxy.insert(4, ' + CHBIPosEntryxy.get() + ')\n')
1125  else:
1126  ConfgFile.write('DestroyXYScreen()\n')
1127  if IAScreenStatus.get() > 0:
1128  ConfgFile.write('GRWIA = ' + str(GRWIA) + '\n')
1129  ConfgFile.write('GRHIA = ' + str(GRHIA) + '\n')
1130  ConfgFile.write('MakeIAWindow()\n')
1131  ConfgFile.write("iawindow.geometry('+" + str(iawindow.winfo_x()) + '+' + str(iawindow.winfo_y()) + "')\n")
1132  ConfgFile.write('IASource.set(' + str(IASource.get()) + ')\n')
1133  ConfgFile.write('DisplaySeries.set(' + str(DisplaySeries.get()) + ')\n')
1134  ConfgFile.write('RsystemEntry.delete(0,END)\n')
1135  ConfgFile.write('RsystemEntry.insert(5, ' + RsystemEntry.get() + ')\n')
1136  ConfgFile.write('ResScale.delete(0,END)\n')
1137  ConfgFile.write('ResScale.insert(5, ' + ResScale.get() + ')\n')
1138  ConfgFile.write('GainCorEntry.delete(0,END)\n')
1139  ConfgFile.write('GainCorEntry.insert(5, ' + GainCorEntry.get() + ')\n')
1140  ConfgFile.write('PhaseCorEntry.delete(0,END)\n')
1141  ConfgFile.write('PhaseCorEntry.insert(5, ' + PhaseCorEntry.get() + ')\n')
1142  ConfgFile.write('NetworkScreenStatus.set(' + str(NetworkScreenStatus.get()) + ')\n')
1143  else:
1144  ConfgFile.write('DestroyIAScreen()\n')
1145  if SpectrumScreenStatus.get() > 0:
1146  ConfgFile.write('GRWF = ' + str(GRWF) + '\n')
1147  ConfgFile.write('GRHF = ' + str(GRHF) + '\n')
1148  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1149  ConfgFile.write('MakeSpectrumWindow()\n')
1150  ConfgFile.write("freqwindow.geometry('+" + str(freqwindow.winfo_x()) + '+' + str(freqwindow.winfo_y()) + "')\n")
1151  ConfgFile.write('ShowC1_VdB.set(' + str(ShowC1_VdB.get()) + ')\n')
1152  ConfgFile.write('ShowC1_P.set(' + str(ShowC1_P.get()) + ')\n')
1153  ConfgFile.write('ShowC2_VdB.set(' + str(ShowC2_VdB.get()) + ')\n')
1154  ConfgFile.write('ShowC2_P.set(' + str(ShowC2_P.get()) + ')\n')
1155  ConfgFile.write('StartFreqEntry.delete(0,END)\n')
1156  ConfgFile.write('StartFreqEntry.insert(5, ' + StartFreqEntry.get() + ')\n')
1157  ConfgFile.write('StopFreqEntry.delete(0,END)\n')
1158  ConfgFile.write('StopFreqEntry.insert(5, ' + StopFreqEntry.get() + ')\n')
1159  ConfgFile.write('HScale.set(' + str(HScale.get()) + ')\n')
1160  ConfgFile.write('FreqTraceMode.set(' + str(FreqTraceMode.get()) + ')\n')
1161  ConfgFile.write('SingleShotSA.set(' + str(SingleShotSA.get()) + ')\n')
1162  else:
1163  ConfgFile.write('DestroySpectrumScreen()\n')
1164  #
1165  if DacScreenStatus.get() > 0:
1166  ConfgFile.write('MakeDacScreen()\n')
1167  ConfgFile.write("win1.geometry('+" + str(win1.winfo_x()) + '+' + str(win1.winfo_y()) + "')\n")
1168  else:
1169  ConfgFile.write('DestroyDacScreen()\n')
1170  if DigScreenStatus.get() > 0:
1171  ConfgFile.write('MakeDigScreen()\n')
1172  ConfgFile.write("win2.geometry('+" + str(win2.winfo_x()) + '+' + str(win2.winfo_y()) + "')\n")
1173  else:
1174  ConfgFile.write('DestroyDigScreen()\n')
1175  if EnableHSsampling > 0:
1176  ConfgFile.write('FminEntry.delete(0,"end")\n')
1177  ConfgFile.write('FminEntry.insert(0, ' + FminEntry.get() + ')\n')
1178  ConfgFile.write('HtMulEntry.delete(0,"end")\n')
1179  ConfgFile.write('HtMulEntry.insert(0, ' + HtMulEntry.get() + ')\n')
1180  ConfgFile.write('Auto_ETS_Comp.set(' + str(Auto_ETS_Comp.get()) + ')\n')
1181  try:
1182  ConfgFile.write('ets_TC1Entry.delete(0,"end")\n')
1183  ConfgFile.write('ets_TC1Entry.insert(0, ' + ets_TC1Entry.get() + ')\n')
1184  ConfgFile.write('ETS_TC1.set(' + ets_TC1Entry.get() + ')\n')
1185  ConfgFile.write('ets_A1Entry.delete(0,"end")\n')
1186  ConfgFile.write('ets_A1Entry.insert(0, ' + ets_A1Entry.get() + ')\n')
1187  ConfgFile.write('ETS_A1.set(' + ets_A1Entry.get() + ')\n')
1188  ConfgFile.write('ets_TC2Entry.delete(0,"end")\n')
1189  ConfgFile.write('ets_TC2Entry.insert(0, ' + ets_TC2Entry.get() + ')\n')
1190  ConfgFile.write('ETS_TC2.set(' + ets_TC2Entry.get() + ')\n')
1191  ConfgFile.write('ets_A2Entry.delete(0,"end")\n')
1192  ConfgFile.write('ets_A2Entry.insert(0, ' + ets_A2Entry.get() + ')\n')
1193  ConfgFile.write('ETS_A2.set(' + ets_A2Entry.get() + ')\n')
1194  except:
1195  ConfgFile.write('ETS_TC1.set(' + str(ETS_TC1.get()) + ')\n')
1196  ConfgFile.write('ETS_A1.set(' + str(ETS_A1.get()) + ')\n')
1197  ConfgFile.write('ETS_TC2.set(' + str(ETS_TC2.get()) + ')\n')
1198  ConfgFile.write('ETS_A2.set(' + str(ETS_A2.get()) + ')\n')
1199  if DigFiltStatus.get() == 1:
1200  ConfgFile.write('MakeDigFiltWindow()\n')
1201  ConfgFile.write("digfltwindow.geometry('+" + str(digfltwindow.winfo_x()) + '+' + str(digfltwindow.winfo_y()) + "')\n")
1202  ConfgFile.write('DigFiltABoxCar.set(' + str(DigFiltABoxCar.get()) + ')\n')
1203  ConfgFile.write('DigFiltBBoxCar.set(' + str(DigFiltBBoxCar.get()) + ')\n')
1204  ConfgFile.write('BCALenEntry.delete(0,"end")\n')
1205  ConfgFile.write('BCALenEntry.insert(0, ' + BCALenEntry.get() + ')\n')
1206  ConfgFile.write('BCBLenEntry.delete(0,"end")\n')
1207  ConfgFile.write('BCBLenEntry.insert(0, ' + BCBLenEntry.get() + ')\n')
1208  ConfgFile.write('AWGALenEntry.delete(0,"end")\n')
1209  ConfgFile.write('AWGALenEntry.insert(0, ' + AWGALenEntry.get() + ')\n')
1210  ConfgFile.write('AWGFiltABoxCar.set(' + str(AWGFiltABoxCar.get()) + ')\n')
1211  ConfgFile.write('AWGBLenEntry.delete(0,"end")\n')
1212  ConfgFile.write('AWGBLenEntry.insert(0, ' + AWGBLenEntry.get() + ')\n')
1213  ConfgFile.write('AWGFiltBBoxCar.set(' + str(AWGFiltBBoxCar.get()) + ')\n')
1214  ConfgFile.write('BuildBoxCarA()\n')
1215  ConfgFile.write('BuildBoxCarB()\n')
1216  ConfgFile.write('BuildAWGBoxCarA()\n')
1217  ConfgFile.write('BuildAWGBoxCarB()\n')
1218  else:
1219  ConfgFile.write('DestroyDigFiltScreen()\n')
1220  if MinigenScreenStatus.get() == 1:
1221  ConfgFile.write('MakeMinigenWindow()\n')
1222  ConfgFile.write("minigenwindow.geometry('+" + str(minigenwindow.winfo_x()) + '+' + str(minigenwindow.winfo_y()) + "')\n")
1223  ConfgFile.write('MinigenMode.set(' + str(MinigenMode.get()) + ')\n')
1224  ConfgFile.write('MinigenFout.delete(0,END)\n')
1225  ConfgFile.write('MinigenFout.insert(4, ' + MinigenFout.get() + ')\n')
1226  ConfgFile.write('MinigenFclk.delete(0,END)\n')
1227  ConfgFile.write('MinigenFclk.insert(4, ' + MinigenFclk.get() + ')\n')
1228  ConfgFile.write('SCLKPort.set(' + str(SCLKPort.get()) + ')\n')
1229  ConfgFile.write('SDATAPort.set(' + str(SDATAPort.get()) + ')\n')
1230  ConfgFile.write('SLATCHPort.set(' + str(SLATCHPort.get()) + ')\n')
1231  else:
1232  ConfgFile.write('DestroyMinigenScreen()\n')
1233  if MuxScreenStatus.get() == 1:
1234  ConfgFile.write('MakeMuxModeWindow()\n')
1235  ConfgFile.write("muxwindow.geometry('+" + str(muxwindow.winfo_x()) + '+' + str(muxwindow.winfo_y()) + "')\n")
1236  ConfgFile.write('Show_CBA.set(' + str(Show_CBA.get()) + ')\n')
1237  ConfgFile.write('Show_CBB.set(' + str(Show_CBB.get()) + ')\n')
1238  ConfgFile.write('Show_CBC.set(' + str(Show_CBC.get()) + ')\n')
1239  ConfgFile.write('Show_CBD.set(' + str(Show_CBD.get()) + ')\n')
1240  ConfgFile.write('MuxEnb.set(' + str(MuxEnb.get()) + ')\n')
1241  ConfgFile.write('DualMuxMode.set(' + str(DualMuxMode.get()) + ')\n')
1242  ConfgFile.write('ChopMuxMode.set(' + str(ChopMuxMode.get()) + ')\n')
1243  ConfgFile.write('ChopTrig.set(' + str(ChopTrig.get()) + ')\n')
1244  ConfgFile.write('CHB_Asb.delete(0,END)\n')
1245  ConfgFile.write('CHB_Asb.insert(0, ' + CHB_Asb.get() + ')\n')
1246  ConfgFile.write('CHB_Bsb.delete(0,END)\n')
1247  ConfgFile.write('CHB_Bsb.insert(0, ' + CHB_Bsb.get() + ')\n')
1248  ConfgFile.write('CHB_Csb.delete(0,END)\n')
1249  ConfgFile.write('CHB_Csb.insert(0, ' + CHB_Csb.get() + ')\n')
1250  ConfgFile.write('CHB_Dsb.delete(0,END)\n')
1251  ConfgFile.write('CHB_Dsb.insert(0, ' + CHB_Dsb.get() + ')\n')
1252  ConfgFile.write('CHB_APosEntry.delete(0,END)\n')
1253  ConfgFile.write('CHB_APosEntry.insert(4, ' + CHB_APosEntry.get() + ')\n')
1254  ConfgFile.write('CHB_BPosEntry.delete(0,END)\n')
1255  ConfgFile.write('CHB_BPosEntry.insert(4, ' + CHB_BPosEntry.get() + ')\n')
1256  ConfgFile.write('CHB_CPosEntry.delete(0,END)\n')
1257  ConfgFile.write('CHB_CPosEntry.insert(4, ' + CHB_CPosEntry.get() + ')\n')
1258  ConfgFile.write('CHB_DPosEntry.delete(0,END)\n')
1259  ConfgFile.write('CHB_DPosEntry.insert(4, ' + CHB_DPosEntry.get() + ')\n')
1260  else:
1261  ConfgFile.write('DestroyMuxScreen()\n')
1262  # Save Phase Anayzer stuff after Analog Mux in case they are both open
1263  if PhAScreenStatus.get() > 0:
1264  ConfgFile.write('GRWPhA = ' + str(GRWPhA) + '\n')
1265  ConfgFile.write('GRHPhA = ' + str(GRHPhA) + '\n')
1266  ConfgFile.write('MakePhAWindow()\n')
1267  ConfgFile.write("phawindow.geometry('+" + str(phawindow.winfo_x()) + '+' + str(phawindow.winfo_y()) + "')\n")
1268  ConfgFile.write('VScale.delete(0,END)\n')
1269  ConfgFile.write('VScale.insert(0, ' + str(VScale.get()) + ')\n')
1270  ConfgFile.write('IScale.delete(0,END)\n')
1271  ConfgFile.write('IScale.insert(0, ' + str(IScale.get()) + ')\n')
1272  ConfgFile.write('RefphEntry.delete(0,END)\n')
1273  ConfgFile.write('RefphEntry.insert(0, "' + str(RefphEntry.get()) + '")\n')
1274  if vat_btn.config('text')[-1] == 'OFF':
1275  ConfgFile.write('vat_btn.config(text="OFF", style="Stop.TButton")\n')
1276  else:
1277  ConfgFile.write('vat_btn.config(text="ON", style="Run.TButton")\n')
1278  if MuxScreenStatus.get() == 0: # these buttons do not exist if Mux screen open
1279  if vbt_btn.config('text')[-1] == 'OFF':
1280  ConfgFile.write('vbt_btn.config(text="OFF", style="Stop.TButton")\n')
1281  else:
1282  ConfgFile.write('vbt_btn.config(text="ON", style="Run.TButton")\n')
1283  if vabt_btn.config('text')[-1] == 'OFF':
1284  ConfgFile.write('vabt_btn.config(text="OFF", style="Stop.TButton")\n')
1285  else:
1286  ConfgFile.write('vabt_btn.config(text="ON", style="Run.TButton")\n')
1287  else: # But these do
1288  ConfgFile.write('ShowPB_A.set(' + str(ShowPB_A.get()) + ')\n')
1289  ConfgFile.write('ShowPB_B.set(' + str(ShowPB_B.get()) + ')\n')
1290  ConfgFile.write('ShowPB_C.set(' + str(ShowPB_C.get()) + ')\n')
1291  ConfgFile.write('ShowPB_D.set(' + str(ShowPB_D.get()) + ')\n')
1292  if iat_btn.config('text')[-1] == 'OFF':
1293  ConfgFile.write('iat_btn.config(text="OFF", style="Stop.TButton")\n')
1294  else:
1295  ConfgFile.write('iat_btn.config(text="ON", style="Run.TButton")\n')
1296  if ibt_btn.config('text')[-1] == 'OFF':
1297  ConfgFile.write('ibt_btn.config(text="OFF", style="Stop.TButton")\n')
1298  else:
1299  ConfgFile.write('ibt_btn.config(text="ON", style="Run.TButton")\n')
1300  if iapbt_btn.config('text')[-1] == 'OFF':
1301  ConfgFile.write('iapbt_btn.config(text="OFF", style="Stop.TButton")\n')
1302  else:
1303  ConfgFile.write('iapbt_btn.config(text="ON", style="Run.TButton")\n')
1304  #
1305  else:
1306  ConfgFile.write('DestroyPhAScreen()\n')
1307  if BodeScreenStatus.get() == 1:
1308  ConfgFile.write('GRWBP = ' + str(GRWBP) + '\n')
1309  ConfgFile.write('GRHBP = ' + str(GRHBP) + '\n')
1310  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1311  ConfgFile.write('ImpedanceCenter.set(' + str(ImpedanceCenter.get()) + ')\n')
1312  ConfgFile.write('MakeBodeWindow()\n')
1313  ConfgFile.write("bodewindow.geometry('+" + str(bodewindow.winfo_x()) + '+' + str(bodewindow.winfo_y()) + "')\n")
1314  ConfgFile.write('ShowCA_VdB.set(' + str(ShowCA_VdB.get()) + ')\n')
1315  ConfgFile.write('ShowCB_VdB.set(' + str(ShowCB_VdB.get()) + ')\n')
1316  ConfgFile.write('ShowCA_P.set(' + str(ShowCA_P.get()) + ')\n')
1317  ConfgFile.write('ShowCB_P.set(' + str(ShowCB_P.get()) + ')\n')
1318  ConfgFile.write('ShowCA_RdB.set(' + str(ShowCA_RdB.get()) + ')\n')
1319  ConfgFile.write('ShowCA_RP.set(' + str(ShowCA_RP.get()) + ')\n')
1320  ConfgFile.write('ShowCB_RdB.set(' + str(ShowCB_RdB.get()) + ')\n')
1321  ConfgFile.write('ShowCB_RP.set(' + str(ShowCB_RP.get()) + ')\n')
1322  ConfgFile.write('BodeDisp.set(' + str(BodeDisp.get()) + ')\n')
1323  ConfgFile.write('ShowMarkerBP.set(' + str(ShowMarkerBP.get()) + ')\n')
1324  ConfgFile.write('ShowMathBP.set(' + str(ShowMathBP.get()) + ')\n')
1325  ConfgFile.write('ShowRMathBP.set(' + str(ShowRMathBP.get()) + ')\n')
1326  ConfgFile.write('HScaleBP.set(' + str(HScaleBP.get()) + ')\n')
1327  ConfgFile.write('NSteps.set(' + str(NSteps.get()) + ')\n')
1328  ConfgFile.write('DBdivindexBP.set(' + str(DBdivindexBP.get()) + ')\n')
1329  ConfgFile.write('DBlevelBP.set(' + str(DBlevelBP.get()) + ')\n')
1330  ConfgFile.write('FSweepMode.set(' + str(FSweepMode.get()) + ')\n')
1331  ConfgFile.write('SweepStepBodeEntry.delete(0,END)\n')
1332  ConfgFile.write('SweepStepBodeEntry.insert(4, ' + SweepStepBodeEntry.get() + ')\n')
1333  ConfgFile.write('StopBodeEntry.delete(0,END)\n')
1334  ConfgFile.write('StopBodeEntry.insert(4, ' + StopBodeEntry.get() + ')\n')
1335  ConfgFile.write('StartBodeEntry.delete(0,END)\n')
1336  ConfgFile.write('StartBodeEntry.insert(4, ' + StartBodeEntry.get() + ')\n')
1337  ConfgFile.write('Show_Rseries.set(' + str(Show_Rseries.get()) + ')\n')
1338  ConfgFile.write('Show_Xseries.set(' + str(Show_Xseries.get()) + ')\n')
1339  ConfgFile.write('Show_Magnitude.set(' + str(Show_Magnitude.get()) + ')\n')
1340  ConfgFile.write('Show_Angle.set(' + str(Show_Angle.get()) + ')\n')
1341  else:
1342  ConfgFile.write('DestroyBodeScreen()\n')
1343  if MeasureStatus.get() == 1:
1344  # Save strings
1345  ConfgFile.write('ChaLableSrring1 = "' + ChaLableSrring1 + '"\n')
1346  ConfgFile.write('ChaLableSrring2 = "' + ChaLableSrring2 + '"\n')
1347  ConfgFile.write('ChaLableSrring3 = "' + ChaLableSrring3 + '"\n')
1348  ConfgFile.write('ChaLableSrring4 = "' + ChaLableSrring4 + '"\n')
1349  ConfgFile.write('ChaLableSrring5 = "' + ChaLableSrring5 + '"\n')
1350  ConfgFile.write('ChaLableSrring6 = "' + ChaLableSrring6 + '"\n')
1351  ConfgFile.write('ChbLableSrring1 = "' + ChbLableSrring1 + '"\n')
1352  ConfgFile.write('ChbLableSrring2 = "' + ChbLableSrring2 + '"\n')
1353  ConfgFile.write('ChbLableSrring3 = "' + ChbLableSrring3 + '"\n')
1354  ConfgFile.write('ChbLableSrring4 = "' + ChbLableSrring4 + '"\n')
1355  ConfgFile.write('ChbLableSrring5 = "' + ChbLableSrring5 + '"\n')
1356  ConfgFile.write('ChbLableSrring6 = "' + ChbLableSrring6 + '"\n')
1357  ConfgFile.write('ChaMeasString1 = "' + ChaMeasString1 + '"\n')
1358  ConfgFile.write('ChaMeasString2 = "' + ChaMeasString2 + '"\n')
1359  ConfgFile.write('ChaMeasString3 = "' + ChaMeasString3 + '"\n')
1360  ConfgFile.write('ChaMeasString4 = "' + ChaMeasString4 + '"\n')
1361  ConfgFile.write('ChaMeasString5 = "' + ChaMeasString5 + '"\n')
1362  ConfgFile.write('ChaMeasString6 = "' + ChaMeasString6 + '"\n')
1363  ConfgFile.write('ChbMeasString1 = "' + ChbMeasString1 + '"\n')
1364  ConfgFile.write('ChbMeasString2 = "' + ChbMeasString2 + '"\n')
1365  ConfgFile.write('ChbMeasString3 = "' + ChbMeasString3 + '"\n')
1366  ConfgFile.write('ChbMeasString4 = "' + ChbMeasString4 + '"\n')
1367  ConfgFile.write('ChbMeasString5 = "' + ChbMeasString5 + '"\n')
1368  ConfgFile.write('ChbMeasString6 = "' + ChbMeasString6 + '"\n')
1369  ConfgFile.write('MakeMeasureScreen()\n')
1370  ConfgFile.write("measurewindow.geometry('+" + str(measurewindow.winfo_x()) + '+' + str(measurewindow.winfo_y()) + "')\n")
1371  else:
1372  ConfgFile.write('DestroyMeasuewScreen()\n')
1373  if ETSStatus.get() == 1: #
1374  ConfgFile.write('MakeETSWindow()\n')
1375  ConfgFile.write("etswindow.geometry('+" + str(etswindow.winfo_x()) + '+' + str(etswindow.winfo_y()) + "')\n")
1376  ConfgFile.write('ETSDisp.set(' + str(ETSDisp.get()) + ')\n')
1377  ConfgFile.write('ETSDir.set(' + str(ETSDir.get()) + ')\n')
1378  ConfgFile.write('FMulXEntry.delete(0,END)\n')
1379  ConfgFile.write('FMulXEntry.insert(6, ' + FMulXEntry.get() + ')\n')
1380  ConfgFile.write('DivXEntry.delete(0,END)\n')
1381  ConfgFile.write('DivXEntry.insert(4, ' + DivXEntry.get() + ')\n')
1382  ConfgFile.write('ETSts.delete(0,END)\n')
1383  ConfgFile.write('ETSts.insert(4, ' + ETSts.get() + ')\n')
1384  else:
1385  ConfgFile.write('DestroyETSScreen()\n')
1386  #
1387  ConfgFile.write('TRIGGERentry.delete(0,END)\n')
1388  ConfgFile.write('TRIGGERentry.insert(4, ' + TRIGGERentry.get() + ')\n')
1389  ConfgFile.write('HoldOffentry.delete(0,"end")\n')
1390  ConfgFile.write('HoldOffentry.insert(0, ' + HoldOffentry.get() + ')\n')
1391  ConfgFile.write('HozPossentry.delete(0,"end")\n')
1392  ConfgFile.write('HozPossentry.insert(0, ' + HozPossentry.get() + ')\n')
1393  ConfgFile.write('TMsb.delete(0,END)\n')
1394  ConfgFile.write('TMsb.insert(0, ' + TMsb.get() + ')\n')
1395  ConfgFile.write('TgInput.set(' + str(TgInput.get()) + ')\n')
1396  ConfgFile.write('AutoLevel.set(' + str(AutoLevel.get()) + ')\n')
1397  ConfgFile.write('ManualTrigger.set(' + str(ManualTrigger.get()) + ')\n')
1398  ConfgFile.write('SingleShot.set(' + str(SingleShot.get()) + ')\n')
1399  ConfgFile.write('TgEdge.set(' + str(TgEdge.get()) + ')\n')
1400  ConfgFile.write('Roll_Mode.set(' + str(Roll_Mode.get()) + ')\n')
1401  ConfgFile.write('Xsignal.set(' + str(Xsignal.get()) + ')\n')
1402  ConfgFile.write('YsignalVA.set(' + str(YsignalVA.get()) + ')\n')
1403  ConfgFile.write('YsignalIA.set(' + str(YsignalIA.get()) + ')\n')
1404  ConfgFile.write('YsignalVB.set(' + str(YsignalVB.get()) + ')\n')
1405  ConfgFile.write('YsignalIB.set(' + str(YsignalIB.get()) + ')\n')
1406  ConfgFile.write('YsignalM.set(' + str(YsignalM.get()) + ')\n')
1407  ConfgFile.write('YsignalMX.set(' + str(YsignalMX.get()) + ')\n')
1408  ConfgFile.write('YsignalMY.set(' + str(YsignalMY.get()) + ')\n')
1409  #
1410  ConfgFile.write('TimeDisp.set(' + str(TimeDisp.get()) + ')\n')
1411  ConfgFile.write('XYDisp.set(' + str(XYDisp.get()) + ')\n')
1412  ConfgFile.write('FreqDisp.set(' + str(FreqDisp.get()) + ')\n')
1413  ConfgFile.write('IADisp.set(' + str(IADisp.get()) + ')\n')
1414  ConfgFile.write('ShowC1_V.set(' + str(ShowC1_V.get()) + ')\n')
1415  ConfgFile.write('ShowC1_I.set(' + str(ShowC1_I.get()) + ')\n')
1416  ConfgFile.write('ShowC2_V.set(' + str(ShowC2_V.get()) + ')\n')
1417  ConfgFile.write('ShowC2_I.set(' + str(ShowC2_I.get()) + ')\n')
1418  ConfgFile.write('Show_MathX.set(' + str(Show_MathX.get()) + ')\n')
1419  ConfgFile.write('Show_MathY.set(' + str(Show_MathY.get()) + ')\n')
1420  ConfgFile.write('AutoCenterA.set(' + str(AutoCenterA.get()) + ')\n')
1421  ConfgFile.write('AutoCenterB.set(' + str(AutoCenterB.get()) + ')\n')
1422  ConfgFile.write('TRACEmodeTime.set(' + str(TRACEmodeTime.get()) + ')\n')
1423  #
1424  ConfgFile.write('CHAVPosEntry.delete(0,END)\n')
1425  ConfgFile.write('CHAVPosEntry.insert(4, ' + CHAVPosEntry.get() + ')\n')
1426  ConfgFile.write('CHAIPosEntry.delete(0,END)\n')
1427  ConfgFile.write('CHAIPosEntry.insert(4, ' + CHAIPosEntry.get() + ')\n')
1428  ConfgFile.write('CHAsb.delete(0,END)\n')
1429  ConfgFile.write('CHAsb.insert(0, ' + CHAsb.get() + ')\n')
1430  ConfgFile.write('CHAIsb.delete(0,END)\n')
1431  ConfgFile.write('CHAIsb.insert(0, ' + CHAIsb.get() + ')\n')
1432  #
1433  ConfgFile.write('CHBVPosEntry.delete(0,END)\n')
1434  ConfgFile.write('CHBVPosEntry.insert(4, ' + CHBVPosEntry.get() + ')\n')
1435  ConfgFile.write('CHBIPosEntry.delete(0,END)\n')
1436  ConfgFile.write('CHBIPosEntry.insert(4, ' + CHBIPosEntry.get() + ')\n')
1437  ConfgFile.write('CHBsb.delete(0,END)\n')
1438  ConfgFile.write('CHBsb.insert(0, ' + CHBsb.get() + ')\n')
1439  ConfgFile.write('CHBIsb.delete(0,END)\n')
1440  ConfgFile.write('CHBIsb.insert(0, ' + CHBIsb.get() + ')\n')
1441  # AWG stuff
1442  ConfgFile.write('AWG_Amp_Mode.set('+ str(AWG_Amp_Mode.get()) + ')\n')
1443  ConfgFile.write('AWGAMode.set('+ str(AWGAMode.get()) + ')\n')
1444  ConfgFile.write('AWGAIOMode.set('+ str(AWGAIOMode.get()) + ')\n')
1445  ConfgFile.write('AWGATerm.set('+ str(AWGATerm.get()) + ')\n')
1446  ConfgFile.write('AWGAPhaseDelay.set('+ str(AWGAPhaseDelay.get()) + ')\n')
1447  ConfgFile.write('AWGAAmplEntry.delete(0,END)\n')
1448  ConfgFile.write('AWGAAmplEntry.insert(4, ' + AWGAAmplEntry.get() + ')\n')
1449  ConfgFile.write('AWGAOffsetEntry.delete(0,END)\n')
1450  ConfgFile.write('AWGAOffsetEntry.insert(4, ' + AWGAOffsetEntry.get() + ')\n')
1451  ConfgFile.write('AWGAFreqEntry.delete(0,END)\n')
1452  ConfgFile.write('AWGAFreqEntry.insert(4, ' + AWGAFreqEntry.get() + ')\n')
1453  ConfgFile.write('AWGAPhaseEntry.delete(0,END)\n')
1454  ConfgFile.write('AWGAPhaseEntry.insert(4, ' + AWGAPhaseEntry.get() + ')\n')
1455  ConfgFile.write('AWGADutyCycleEntry.delete(0,END)\n')
1456  ConfgFile.write('AWGADutyCycleEntry.insert(4, ' + AWGADutyCycleEntry.get() + ')\n')
1457  ConfgFile.write('AWGAShape.set(' + str(AWGAShape.get()) + ')\n')
1458  ConfgFile.write('AWGARepeatFlag.set(' + str(AWGARepeatFlag.get()) + ')\n')
1459  ConfgFile.write('AWGABurstFlag.set(' + str(AWGABurstFlag.get()) + ')\n')
1460  ConfgFile.write('global AWGACycles; AWGACycles = ' + str(AWGACycles) + '\n')
1461  ConfgFile.write('global AWGABurstDelay; AWGABurstDelay = ' + str(AWGABurstDelay) + '\n')
1462  #
1463  ConfgFile.write('AWGBMode.set('+ str(AWGBMode.get()) + ')\n')
1464  ConfgFile.write('AWGBIOMode.set('+ str(AWGBIOMode.get()) + ')\n')
1465  ConfgFile.write('AWGBTerm.set('+ str(AWGBTerm.get()) + ')\n')
1466  ConfgFile.write('AWGBPhaseDelay.set('+ str(AWGBPhaseDelay.get()) + ')\n')
1467  ConfgFile.write('AWGBAmplEntry.delete(0,END)\n')
1468  ConfgFile.write('AWGBAmplEntry.insert(4, ' + AWGBAmplEntry.get() + ')\n')
1469  ConfgFile.write('AWGBOffsetEntry.delete(0,END)\n')
1470  ConfgFile.write('AWGBOffsetEntry.insert(4, ' + AWGBOffsetEntry.get() + ')\n')
1471  ConfgFile.write('AWGBFreqEntry.delete(0,END)\n')
1472  ConfgFile.write('AWGBFreqEntry.insert(4, ' + AWGBFreqEntry.get() + ')\n')
1473  ConfgFile.write('AWGBPhaseEntry.delete(0,END)\n')
1474  ConfgFile.write('AWGBPhaseEntry.insert(4, ' + AWGBPhaseEntry.get() + ')\n')
1475  ConfgFile.write('AWGBDutyCycleEntry.delete(0,END)\n')
1476  ConfgFile.write('AWGBDutyCycleEntry.insert(4, ' + AWGBDutyCycleEntry.get() + ')\n')
1477  ConfgFile.write('AWGBShape.set(' + str(AWGBShape.get()) + ')\n')
1478  ConfgFile.write('AWGBRepeatFlag.set(' + str(AWGBRepeatFlag.get()) + ')\n')
1479  ConfgFile.write('AWGBBurstFlag.set(' + str(AWGBBurstFlag.get()) + ')\n')
1480  ConfgFile.write('global AWGBCycles; AWGBCycles = ' + str(AWGBCycles) + '\n')
1481  ConfgFile.write('global AWGBBurstDelay; AWGBBurstDelay = ' + str(AWGBBurstDelay) + '\n')
1482  #
1483  ConfgFile.write('AWGSync.set(' + str(AWGSync.get()) + ')\n')
1484  ConfgFile.write('AWGAMathString = "' + AWGAMathString + '"\n')
1485  ConfgFile.write('AWGBMathString = "' + AWGBMathString + '"\n')
1486  ConfgFile.write('AWGAcsvFile = "' + AWGAcsvFile + '"\n')
1487  ConfgFile.write('AWGBcsvFile = "' + AWGBcsvFile + '"\n')
1488  ConfgFile.write('AWGAwavFile = "' + AWGAwavFile + '"\n')
1489  ConfgFile.write('AWGBwavFile = "' + AWGBwavFile + '"\n')
1490  #
1491  if EnableScopeOnly == 0:
1492  ConfgFile.write('AWGANoiseEntry.delete(0,END)\n')
1493  ConfgFile.write('AWGANoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1494  ConfgFile.write('AWGBNoiseEntry.delete(0,END)\n')
1495  ConfgFile.write('AWGBNoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1496  ConfgFile.write('AWGAsbnoise.delete(0,END)\n')
1497  ConfgFile.write('AWGAsbnoise.insert(4, "'+ str(AWGAsbnoise.get()) + '")\n')
1498  ConfgFile.write('AWGBsbnoise.delete(0,END)\n')
1499  ConfgFile.write('AWGBsbnoise.insert(4, "' + str(AWGBsbnoise.get()) + '")\n')
1500  #
1501  ConfgFile.write('CHAVGainEntry.delete(0,END)\n')
1502  ConfgFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1503  ConfgFile.write('CHBVGainEntry.delete(0,END)\n')
1504  ConfgFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1505  ConfgFile.write('CHAVOffsetEntry.delete(0,END)\n')
1506  ConfgFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1507  ConfgFile.write('CHBVOffsetEntry.delete(0,END)\n')
1508  ConfgFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1509  #
1510  ConfgFile.write('MeasDCV1.set(' + str(MeasDCV1.get()) + ')\n')
1511  ConfgFile.write('MeasMinV1.set(' + str(MeasMinV1.get()) + ')\n')
1512  ConfgFile.write('MeasMaxV1.set(' + str(MeasMaxV1.get()) + ')\n')
1513  ConfgFile.write('MeasBaseV1.set(' + str(MeasBaseV1.get()) + ')\n')
1514  ConfgFile.write('MeasTopV1.set(' + str(MeasTopV1.get()) + ')\n')
1515  ConfgFile.write('MeasMidV1.set(' + str(MeasMidV1.get()) + ')\n')
1516  ConfgFile.write('MeasPPV1.set(' + str(MeasPPV1.get()) + ')\n')
1517  ConfgFile.write('MeasRMSV1.set(' + str(MeasRMSV1.get()) + ')\n')
1518  ConfgFile.write('MeasDCI1.set(' + str(MeasDCI1.get()) + ')\n')
1519  ConfgFile.write('MeasMinI1.set(' + str(MeasMinI1.get()) + ')\n')
1520  ConfgFile.write('MeasMaxI1.set(' + str(MeasMaxI1.get()) + ')\n')
1521  ConfgFile.write('MeasMidI1.set(' + str(MeasMidI1.get()) + ')\n')
1522  ConfgFile.write('MeasPPI1.set(' + str(MeasPPI1.get()) + ')\n')
1523  ConfgFile.write('MeasRMSI1.set(' + str(MeasRMSI1.get()) + ')\n')
1524  ConfgFile.write('MeasDiffAB.set(' + str(MeasDiffAB.get()) + ')\n')
1525  ConfgFile.write('MeasDCV2.set(' + str(MeasDCV2.get()) + ')\n')
1526  ConfgFile.write('MeasMinV2.set(' + str(MeasMinV2.get()) + ')\n')
1527  ConfgFile.write('MeasMaxV2.set(' + str(MeasMaxV2.get()) + ')\n')
1528  ConfgFile.write('MeasBaseV2.set(' + str(MeasBaseV2.get()) + ')\n')
1529  ConfgFile.write('MeasTopV2.set(' + str(MeasTopV2.get()) + ')\n')
1530  ConfgFile.write('MeasMidV2.set(' + str(MeasMidV2.get()) + ')\n')
1531  ConfgFile.write('MeasPPV2.set(' + str(MeasPPV2.get()) + ')\n')
1532  ConfgFile.write('MeasRMSV2.set(' + str(MeasRMSV2.get()) + ')\n')
1533  ConfgFile.write('MeasDCI2.set(' + str(MeasDCI2.get()) + ')\n')
1534  ConfgFile.write('MeasMinI2.set(' + str(MeasMinI2.get()) + ')\n')
1535  ConfgFile.write('MeasMaxI2.set(' + str(MeasMaxI2.get()) + ')\n')
1536  ConfgFile.write('MeasMidI2.set(' + str(MeasMidI2.get()) + ')\n')
1537  ConfgFile.write('MeasPPI2.set(' + str(MeasPPI2.get()) + ')\n')
1538  ConfgFile.write('MeasRMSI2.set(' + str(MeasRMSI2.get()) + ')\n')
1539  ConfgFile.write('MeasDiffBA.set(' + str(MeasDiffBA.get()) + ')\n')
1540  #
1541  ConfgFile.write('MeasAHW.set(' + str(MeasAHW.get()) + ')\n')
1542  ConfgFile.write('MeasALW.set(' + str(MeasALW.get()) + ')\n')
1543  ConfgFile.write('MeasADCy.set(' + str(MeasADCy.get()) + ')\n')
1544  ConfgFile.write('MeasAPER.set(' + str(MeasAPER.get()) + ')\n')
1545  ConfgFile.write('MeasAFREQ.set(' + str(MeasAFREQ.get()) + ')\n')
1546  ConfgFile.write('MeasBHW.set(' + str(MeasBHW.get()) + ')\n')
1547  ConfgFile.write('MeasBLW.set(' + str(MeasBLW.get()) + ')\n')
1548  ConfgFile.write('MeasBDCy.set(' + str(MeasBDCy.get()) + ')\n')
1549  ConfgFile.write('MeasBPER.set(' + str(MeasBPER.get()) + ')\n')
1550  ConfgFile.write('MeasBFREQ.set(' + str(MeasBFREQ.get()) + ')\n')
1551  ConfgFile.write('MeasPhase.set(' + str(MeasPhase.get()) + ')\n')
1552  ConfgFile.write('MeasDelay.set(' + str(MeasDelay.get()) + ')\n')
1553  #
1554  ConfgFile.write('MathTrace.set(' + str(MathTrace.get()) + ')\n')
1555  #
1556  ConfgFile.write('CHAIGainEntry.delete(0,END)\n')
1557  ConfgFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1558  ConfgFile.write('CHBIGainEntry.delete(0,END)\n')
1559  ConfgFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1560  ConfgFile.write('CHAIOffsetEntry.delete(0,END)\n')
1561  ConfgFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1562  ConfgFile.write('CHBIOffsetEntry.delete(0,END)\n')
1563  ConfgFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1564  # Save strings
1565  ConfgFile.write('UserAString = "' + UserAString + '"\n')
1566  ConfgFile.write('UserALabel = "' + UserALabel + '"\n')
1567  ConfgFile.write('UserBString = "' + UserBString + '"\n')
1568  ConfgFile.write('UserBLabel = "' + UserBLabel + '"\n')
1569  ConfgFile.write('FFTUserWindowString= "' + FFTUserWindowString + '"\n')
1570  ConfgFile.write('DigFilterAString = "' + DigFilterAString + '"\n')
1571  ConfgFile.write('DigFilterBString = "' + DigFilterBString + '"\n')
1572  # save channel AC frequency compensation settings
1573  try:
1574  CHA_TC1.set(float(cha_TC1Entry.get()))
1575  CHA_TC2.set(float(cha_TC2Entry.get()))
1576  CHB_TC1.set(float(chb_TC1Entry.get()))
1577  CHB_TC2.set(float(chb_TC2Entry.get()))
1578  CHA_A1.set(float(cha_A1Entry.get()))
1579  CHA_A2.set(float(cha_A2Entry.get()))
1580  CHB_A1.set(float(chb_A1Entry.get()))
1581  CHB_A2.set(float(chb_A2Entry.get()))
1582  except:
1583  donothing()
1584  ConfgFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1585  ConfgFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1586  ConfgFile.write('CHAI_RC_HP.set(' + str(CHAI_RC_HP.get()) + ')\n')
1587  ConfgFile.write('CHBI_RC_HP.set(' + str(CHBI_RC_HP.get()) + ')\n')
1588  ConfgFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1589  ConfgFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1590  ConfgFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1591  ConfgFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1592  ConfgFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1593  ConfgFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1594  ConfgFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1595  ConfgFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1596  ConfgFile.write('cha_TC1Entry.delete(0,END)\n')
1597  ConfgFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1598  ConfgFile.write('cha_TC2Entry.delete(0,END)\n')
1599  ConfgFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1600  ConfgFile.write('chb_TC1Entry.delete(0,END)\n')
1601  ConfgFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1602  ConfgFile.write('chb_TC2Entry.delete(0,END)\n')
1603  ConfgFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1604  ConfgFile.write('cha_A1Entry.delete(0,END)\n')
1605  ConfgFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1606  ConfgFile.write('cha_A2Entry.delete(0,END)\n')
1607  ConfgFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1608  ConfgFile.write('chb_A1Entry.delete(0,END)\n')
1609  ConfgFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1610  ConfgFile.write('chb_A2Entry.delete(0,END)\n')
1611  ConfgFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1612 
1613  # extra Spectrum stuff
1614  if SpectrumScreenStatus.get() > 0 or IAScreenStatus.get() > 0 or BodeScreenStatus.get() > 0:
1615  ConfgFile.write('SMPfftpwrTwo.set(' + str(SMPfftpwrTwo.get()) + ')\n')
1616  ConfgFile.write('FFTwindow.set(' + str(FFTwindow.get()) + ')\n')
1617  ConfgFile.write('ZEROstuffing.set(' + str(ZEROstuffing.get()) + ')\n')
1618  ConfgFile.write('Vdiv.set(' + str(Vdiv.get()) + ')\n')
1619  #
1620  ConfgFile.write('DBdivindex.set(' + str(DBdivindex.get()) + ')\n')
1621  ConfgFile.write('DBlevel.set(' + str(DBlevel.get()) + ')\n')
1622  # ConfgFile.write('TRACEaverage.set(' + str(TRACEaverage.get()) + ')\n')
1623  ConfgFile.write('CutDC.set(' + str(CutDC.get()) + ')\n')
1624  #
1625  ConfgFile.close()
1626 
1627 def BSaveConfigIA():
1628  global iawindow
1629 
1630  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1631  BSaveConfig(filename)
1632 
1633 def BSaveConfigSA():
1634  global freqwindow
1635 
1636  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1637  BSaveConfig(filename)
1638 
1639 def BSaveConfigBP():
1640  global bodewindow
1641 
1642  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1643  BSaveConfig(filename)
1644 
1645 def BSaveConfigTime():
1646  global root
1647  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1648  BSaveConfig(filename)
1649 
1650 def BLoadConfig(filename):
1651  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1652  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1653  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
1654  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
1655  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1656  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1657  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1658  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1659  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1660  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1661  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1662  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1663  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1664  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1665  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1666  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1667  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1668  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1669  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1670  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1671  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1672  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1673  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1674  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1675  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1676  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1677  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1678  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1679  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
1680  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1681  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1682  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1683  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1684  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1685  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1686  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1687  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1688  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1689  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1690  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1691  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1692  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1693  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1694  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
1695  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
1696  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1697  global phawindow, PhAca, PhAScreenStatus, PhADisp
1698  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
1699  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
1700  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, iapbt_btn, RollBt, Roll_Mode
1701  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1702  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
1703  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1704  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1705  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1706  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
1707  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
1708  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
1709  # Read configuration values from file
1710  try:
1711  ConfgFile = open(filename)
1712  for line in ConfgFile:
1713  try:
1714  exec( line.rstrip(), globals(), globals())
1715  #exec( line.rstrip() )
1716  except:
1717  print( "Skipping " + line.rstrip())
1718  ConfgFile.close()
1719  if ScreenWidth < root.winfo_x() or ScreenHeight < root.winfo_y(): # check if main window will be placed off screen?
1720  root.geometry('+0+0')
1721  try:
1722  if ScreenWidth < awgwindow.winfo_x() or ScreenHeight < awgwindow.winfo_y(): # check if AWG window will be placed off screen?
1723  awgwindow.geometry('+0+0')
1724  except:
1725  donothing()
1726  try:
1727  if ScreenWidth < xywindow.winfo_x() or ScreenHeight< xywindow.winfo_y(): # check if XY window will be placed off screen?
1728  xywindow.geometry('+0+0')
1729  except:
1730  donothing()
1731  try:
1732  if ScreenWidth < iawindow.winfo_x() or ScreenHeight < iawindow.winfo_y(): # check if IA window will be placed off screen?
1733  iawindow.geometry('+0+0')
1734  except:
1735  donothing()
1736  try:
1737  if ScreenWidth < freqwindow.winfo_x() or ScreenHeight < freqwindow.winfo_y(): # check if SA window will be placed off screen?
1738  freqwindow.geometry('+0+0')
1739  except:
1740  donothing()
1741  try:
1742  if ScreenWidth < win1.winfo_x() or ScreenHeight < win1.winfo_y(): # check if DAC1 window will be placed off screen?
1743  win1.geometry('+0+0')
1744  except:
1745  donothing()
1746  try:
1747  if ScreenWidth < win2.winfo_x() or ScreenHeight < win2.winfo_y(): # check if DAC2 window will be placed off screen?
1748  win2.geometry('+0+0')
1749  except:
1750  donothing()
1751  try:
1752  if ScreenWidth < minigenwindow.winfo_x() or ScreenHeight < minigenwindow.winfo_y(): # check if mini gen window will be placed off screen?
1753  minigenwindow.geometry('+0+0')
1754  except:
1755  donothing()
1756  try:
1757  if ScreenWidth < muxwindow.winfo_x() or ScreenHeight < muxwindow.winfo_y(): # check if mux window will be placed off screen?
1758  muxwindow.geometry('+0+0')
1759  except:
1760  donothing()
1761  try:
1762  if ScreenWidth < phawindow.winfo_x() or ScreenHeight < phawindow.winfo_y(): # check if PhA window will be placed off screen?
1763  phawindow.geometry('+0+0')
1764  except:
1765  donothing()
1766  try:
1767  if ScreenWidth < bodewindow.winfo_x() or ScreenHeight < bodewindow.winfo_y(): # check if Bode window will be placed off screen?
1768  bodewindow.geometry('+0+0')
1769  except:
1770  donothing()
1771  try:
1772  if ScreenWidth < measurewindow.winfo_x() or ScreenHeight < measurewindow.winfo_y(): # check if Measure window will be placed off screen?
1773  measurewindow.geometry('+0+0')
1774  except:
1775  donothing()
1776  try:
1777  if ScreenWidth < etswindow.winfo_x() or ScreenHeight < etswindow.winfo_y(): # check if ETS window will be placed off screen?
1778  etswindow.geometry('+0+0')
1779  except:
1780  donothing()
1781  if Roll_Mode.get() == 0:
1782  RollBt.config(style="RollOff.TButton",text="Roll-Off")
1783  else:
1784  RollBt.config(style="Roll.TButton",text="Roll-On")
1785  if DevID != "No Device":
1786  BAWGAModeLabel()
1787  BAWGBModeLabel()
1788  BAWGAPhaseDelay()
1789  BAWGBPhaseDelay()
1790 
1804  ca.config(background=COLORcanvas)
1805  # Needs to reload from waveform files
1806  if AWGAShape.get()==6:
1807  AWGALoadCSV()
1808  if AWGAShape.get()==13:
1809  AWGALoadWAV()
1810  if AWGBShape.get()==6:
1811  AWGBLoadCSV()
1812  if AWGBShape.get()==13:
1813  AWGBLoadWAV()
1814  # Regenerate waveform from formula
1815  if AWGAShape.get()==10:
1816  AWGAConfigMath()
1817  if AWGBShape.get()==10:
1818  AWGBConfigMath()
1819  if EnableScopeOnly == 0:
1820  UpdateAWGWin()
1821  TimeCheckBox()
1822  XYCheckBox()
1823  FreqCheckBox()
1824  BodeCheckBox()
1825  IACheckBox()
1826  OhmCheckBox()
1827  else:
1828  TimeCheckBox()
1829  XYCheckBox()
1830  UpdateAWGWin()
1831 #
1832  time.sleep(0.05)
1833  ReMakeAWGwaves()
1834  session.end() # Add this to turn off outputs after first time loading a config?
1835  BTime()
1836  except:
1837  print( "Config File Not Found.")
1838 
1839 
1840 def ReMakeAWGwaves(): # re make awg waveforms ib case something changed
1841  global AWGAShape, AWGBShape, BisCompA, AWGAShapeLabel, AWGBShapeLabel
1842  global AWGALength, AWGBLength, AWGAwaveform, AWGBwaveform, EnableScopeOnly
1843 
1844  if AWGAShape.get()==9:
1845  AWGAMakeImpulse()
1846  AWGAShapeLabel.config(text = "Impulse") # change displayed value
1847  elif AWGAShape.get()==11:
1849  AWGAShapeLabel.config(text = "Trapazoid") # change displayed value
1850  elif AWGAShape.get()==15:
1851  AWGAMakeSSQ()
1852  AWGAShapeLabel.config(text = "SSQ Pulse") # change displayed value
1853  elif AWGAShape.get()==16:
1854  AWGAMakeRamp()
1855  AWGAShapeLabel.config(text = "Ramp") # change displayed value
1856  elif AWGAShape.get()==17:
1857  AWGAMakePWMSine()
1858  AWGAShapeLabel.config(text = "PWN Sine") # change displayed value
1859  elif AWGAShape.get()==18:
1861  AWGAShapeLabel.config(text = "Hi Res Sine") # change displayed value
1862  elif AWGAShape.get()==12:
1864  AWGAShapeLabel.config(text = "Up Down Ramp") # change displayed value
1865  elif AWGAShape.get()==14:
1866  AWGAMakeFourier()
1867  AWGAShapeLabel.config(text = "Fourier Series") # change displayed value
1868  elif AWGAShape.get()==19:
1869  AWGAMakeSinc()
1870  AWGAShapeLabel.config(text = "Sinc Pulse") # change displayed value
1871  elif AWGAShape.get()==20:
1872  AWGAMakePulse()
1873  AWGAShapeLabel.config(text = "Pulse") # change displayed value
1874  elif AWGAShape.get()==21:
1875  AWGAMakeFMSine()
1876  AWGAShapeLabel.config(text = "FM Sine") # change displayed value
1877  elif AWGAShape.get()==22:
1878  AWGAMakeAMSine()
1879  AWGAShapeLabel.config(text = "AM Sine") # change displayed value
1880  elif AWGAShape.get()==23:
1882  AWGAShapeLabel.config(text = "Full Wave") # change displayed value
1883  elif AWGAShape.get()==24:
1885  AWGAShapeLabel.config(text = "Half Wave") # change displayed value
1886  elif AWGAShape.get()==7:
1887  AWGAMakeUUNoise()
1888  AWGAShapeLabel.config(text = "UU Noise") # change displayed value
1889  elif AWGAShape.get()==8:
1890  AWGAMakeUGNoise()
1891  AWGAShapeLabel.config(text = "UG Noise") # change displayed value
1892  elif AWGAShape.get()==0:
1893  AWGAShapeLabel.config(text = "DC") # change displayed value
1894  elif AWGAShape.get()==2:
1895  AWGAShapeLabel.config(text = "Triangle") # change displayed value
1896  elif AWGAShape.get()==4:
1897  AWGAShapeLabel.config(text = "Square") # change displayed value
1898  elif AWGAShape.get()==3:
1899  AWGAShapeLabel.config(text = "Saw Tooth") # change displayed value
1900  elif AWGAShape.get()==5:
1901  AWGAShapeLabel.config(text = "Starestep") # change displayed value
1902  elif AWGAShape.get()==6:
1903  AWGAShapeLabel.config(text = "CSV File") # change displayed value
1904  elif AWGAShape.get()==13:
1905  AWGAShapeLabel.config(text = "Wav File") # change displayed value
1906  elif AWGAShape.get()==10:
1907  AWGAShapeLabel.config(text = "Math") # change displayed value
1908  else:
1909  AWGAShapeLabel.config(text = "Other Shape") # change displayed value
1910 #
1911  if BisCompA.get() == 1:
1912  SetBCompA()
1913  if AWGBShape.get()==9:
1914  AWGBMakeImpulse()
1915  AWGBShapeLabel.config(text = "Impulse") # change displayed value
1916  elif AWGBShape.get()==11:
1918  AWGBShapeLabel.config(text = "Trapazoid") # change displayed value
1919  elif AWGBShape.get()==15:
1920  AWGBMakeSSQ()
1921  AWGBShapeLabel.config(text = "SSQ Pulse") # change displayed value
1922  elif AWGBShape.get()==16:
1923  AWGBMakeRamp()
1924  AWGBShapeLabel.config(text = "Ramp") # change displayed value
1925  elif AWGBShape.get()==17:
1926  AWGBMakePWMSine()
1927  AWGBShapeLabel.config(text = "PWN Sine") # change displayed value
1928  elif AWGBShape.get()==18:
1930  AWGBShapeLabel.config(text = "Hi Res Sine") # change displayed value
1931  elif AWGBShape.get()==12:
1933  AWGBShapeLabel.config(text = "Up Down Ramp") # change displayed value
1934  elif AWGBShape.get()==14:
1935  AWGBMakeFourier()
1936  AWGBShapeLabel.config(text = "Fourier Series") # change displayed value
1937  elif AWGBShape.get()==19:
1938  AWGBMakeSinc()
1939  AWGBShapeLabel.config(text = "Sinc Pulse") # change displayed value
1940  elif AWGBShape.get()==20:
1941  AWGBMakePulse()
1942  AWGBShapeLabel.config(text = "Pulse") # change displayed value
1943  elif AWGBShape.get()==23:
1945  AWGBShapeLabel.config(text = "Full Wave") # change displayed value
1946  elif AWGBShape.get()==24:
1948  AWGBShapeLabel.config(text = "Half Wave") # change displayed value
1949  elif AWGBShape.get()==7:
1950  AWGBMakeUUNoise()
1951  AWGBShapeLabel.config(text = "UU Noise") # change displayed value
1952  elif AWGBShape.get()==8:
1953  AWGBMakeUGNoise()
1954  AWGBShapeLabel.config(text = "UG Noise") # change displayed value
1955  elif AWGBShape.get()==0:
1956  AWGBShapeLabel.config(text = "DC") # change displayed value
1957  elif AWGBShape.get()==2:
1958  AWGBShapeLabel.config(text = "Triangle") # change displayed value
1959  elif AWGBShape.get()==4:
1960  AWGBShapeLabel.config(text = "Square") # change displayed value
1961  elif AWGBShape.get()==3:
1962  AWGBShapeLabel.config(text = "Saw Tooth") # change displayed value
1963  elif AWGBShape.get()==5:
1964  AWGBShapeLabel.config(text = "Starestep") # change displayed value
1965  elif AWGBShape.get()==6:
1966  AWGBShapeLabel.config(text = "CSV File") # change displayed value
1967  elif AWGBShape.get()==13:
1968  AWGBShapeLabel.config(text = "Wav File") # change displayed value
1969  elif AWGBShape.get()==10:
1970  AWGBShapeLabel.config(text = "Math") # change displayed value
1971  else:
1972  AWGBShapeLabel.config(text = "Other Shape") # change displayed value
1973  if EnableScopeOnly == 0:
1974  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
1975  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
1976  UpdateAwgCont()
1977  time.sleep(0.05)
1978 
1979 def BLoadConfigIA():
1980  global iawindow
1981 
1982  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1983  BLoadConfig(filename)
1984 
1985 def BLoadConfigSA():
1986  global freqwindow
1987 
1988  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1989  BLoadConfig(filename)
1990 
1991 def BLoadConfigBP():
1992  global bodewindow
1993 
1994  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1995  BLoadConfig(filename)
1996 
1997 def BLoadConfigTime():
1998  global root
1999 
2000  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
2001  BLoadConfig(filename)
2002  UpdateTimeTrace()
2003 
2004 def RunScript():
2005  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
2006  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
2007  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
2008  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
2009  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
2010  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
2011  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
2012  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
2013  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
2014  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
2015  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
2016  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
2017  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
2018  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
2019  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
2020  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
2021  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2022  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
2023  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
2024  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
2025  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
2026  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
2027  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
2028  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2029  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
2030  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
2031  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
2032  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
2033  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
2034  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
2035  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
2036  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
2037  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
2038  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
2039  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
2040  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
2041  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
2042  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
2043  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
2044  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
2045  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
2046  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
2047  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
2048  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2049  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2050  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
2051  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
2052  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
2053  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
2054  global phawindow, PhAca, PhAScreenStatus, PhADisp
2055  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
2056  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
2057  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
2058  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
2059  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
2060  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
2061  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
2062  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
2063  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
2064 
2065  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Script files", "*.txt")], parent=root)
2066  # Read Script commands from file
2067  try:
2068  ConfgFile = open(filename)
2069  for line in ConfgFile:
2070  try:
2071  exec( line.rstrip(), globals(), globals())
2072  # exec( line.rstrip() )
2073  except:
2074  print( "Skipping " + line.rstrip())
2075  showwarning("Syntax Error!",("Syntax Error found in line:\n " + line.rstrip()))
2076  ConfgFile.close()
2077  except:
2078  print( "Config File Not Found.")
2079  showwarning("Warning!","Script File Not Found.")
2080 
2081 
2082 def BgColor():
2083  global COLORtext, COLORcanvas, ColorMode, Bodeca, BodeScreenStatus, PhAca, PhAScreenStatus
2084  global ca, Freqca, SpectrumScreenStatus, XYca, XYScreenStatus, IAca, IAScreenStatus
2085  global COLORtrace4, COLORtraceR4, TRACEwidth
2086 
2087  if ColorMode.get() > 0: # White background
2088  if TRACEwidth.get() < 2:
2089  TRACEwidth.set(2)
2090  COLORtext = "#000000" # 100% black
2091  COLORtrace4 = "#a0a000" # 50% yellow
2092  COLORtraceR4 = "#606000" # 25% yellow
2093  COLORcanvas = "#ffffff" # 100% white
2094  else:
2095  COLORcanvas = "#000000" # 100% black
2096  COLORtrace4 = "#ffff00" # 100% yellow
2097  COLORtraceR4 = "#808000" # 50% yellow
2098  COLORtext = "#ffffff" # 100% white
2099  ca.config(background=COLORcanvas)
2101  if SpectrumScreenStatus.get() > 0:
2102  Freqca.config(background=COLORcanvas)
2104  if XYScreenStatus.get() > 0:
2105  XYca.config(background=COLORcanvas)
2106  UpdateXYScreen()
2107  if PhAScreenStatus.get() > 0:
2108  PhAca.config(background=COLORcanvas)
2109  UpdatePhAScreen()
2110  if IAScreenStatus.get() > 0:
2111  IAca.config(background=COLORcanvas)
2112  UpdateIAScreen()
2113  if BodeScreenStatus.get() > 0:
2114  Bodeca.config(background=COLORcanvas)
2116 
2118  global ColorScreenStatus, FrameBG, SWRev, RevDate, ColorWindow
2119  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
2120  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
2121  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
2122 
2123  if ColorScreenStatus.get() == 0:
2124  ColorScreenStatus.set(1)
2125  #
2126  ColorWindow = Toplevel()
2127  ColorWindow.title("Color Selector " + SWRev + RevDate)
2128  ColorWindow.resizable(FALSE,FALSE)
2129  ColorWindow.protocol("WM_DELETE_WINDOW", DestroyColorScreen)
2130  ColorWindow.configure(background=FrameBG)
2131 
2132  Colorframe1 = LabelFrame(ColorWindow, text="Trace Colors", style="A10R1.TLabelframe") #"A10T5.TLabelframe")
2133  Colorframe1.pack(side=TOP, expand=1, fill=Y)
2134  # Color value = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
2135  trace1bt = Button(Colorframe1, text="COLORtrace1", style="T1W16.TButton", command=SetColorT1 ) #COLORtrace1 = "#00ff00" # 100% green
2136  trace1bt.grid(row=0, column=0, columnspan=1, sticky=W)
2137  #
2138  trace2bt = Button(Colorframe1, text="COLORtrace2", style="T2W16.TButton", command=SetColorT2 ) #COLORtrace2 = "#ff8000" # 100% orange
2139  trace2bt.grid(row=0, column=1, columnspan=1, sticky=W)
2140  #
2141  trace3bt = Button(Colorframe1, text="COLORtrace3", style="T3W16.TButton", command=SetColorT3 ) #COLORtrace3 = "#00ffff" # 100% cyan
2142  trace3bt.grid(row=0, column=2, columnspan=1, sticky=W)
2143  #
2144  trace4bt = Button(Colorframe1, text="COLORtrace4", style="T4W16.TButton", command=SetColorT4 ) #COLORtrace4 = "#ffff00" # 100% yellow
2145  trace4bt.grid(row=0, column=3, columnspan=1, sticky=W)
2146  #
2147  trace5bt = Button(Colorframe1, text="COLORtrace5", style="T5W16.TButton", command=SetColorT5 ) #COLORtrace5 = "#ff00ff" # 100% magenta
2148  trace5bt.grid(row=1, column=0, columnspan=1, sticky=W)
2149  #
2150  trace6bt = Button(Colorframe1, text="COLORtrace6", style="T6W16.TButton", command=SetColorT6 ) #COLORtrace6 = "#C80000" # 90% red
2151  trace6bt.grid(row=1, column=1, columnspan=1, sticky=W)
2152  #
2153  trace7bt = Button(Colorframe1, text="COLORtrace7", style="T7W16.TButton", command=SetColorT7 ) #COLORtrace7 = "#8080ff" # 100% purple
2154  trace7bt.grid(row=1, column=2, columnspan=1, sticky=W)
2155  #
2156  tracer1bt = Button(Colorframe1, text="COLORtraceR1", style="TR1W16.TButton", command=SetColorTR1 ) #COLORtraceR1 = "#008000" # 50% green
2157  tracer1bt.grid(row=2, column=0, columnspan=1, sticky=W)
2158  #
2159  tracer2rbt = Button(Colorframe1, text="COLORtraceR2", style="TR2W16.TButton", command=SetColorTR2 ) #COLORtraceR2 = "#905000" # 50% orange
2160  tracer2rbt.grid(row=2, column=1, columnspan=1, sticky=W)
2161  #
2162  tracer3bt = Button(Colorframe1, text="COLORtraceR3", style="TR3W16.TButton", command=SetColorTR3 ) #COLORtraceR3 = "#008080" # 50% cyan
2163  tracer3bt.grid(row=2, column=2, columnspan=1, sticky=W)
2164  #
2165  tracer4bt = Button(Colorframe1, text="COLORtraceR4", style="TR4W16.TButton", command=SetColorTR4 ) #COLORtraceR4 = "#808000" # 50% yellow
2166  tracer4bt.grid(row=2, column=3, columnspan=1, sticky=W)
2167  #
2168  tracer5bt = Button(Colorframe1, text="COLORtraceR5", style="TR5W16.TButton", command=SetColorTR5 ) #COLORtraceR5 = "#800080" # 50% magenta
2169  tracer5bt.grid(row=3, column=0, columnspan=1, sticky=W)
2170  #
2171  tracer6bt = Button(Colorframe1, text="COLORtraceR6", style="TR6W16.TButton", command=SetColorTR6 ) #COLORtraceR6 = "#800000" # 80% red
2172  tracer6bt.grid(row=3, column=1, columnspan=1, sticky=W)
2173  #
2174  tracer7bt = Button(Colorframe1, text="COLORtraceR7", style="TR7W16.TButton", command=SetColorTR7 ) #COLORtraceR7 = "#4040a0" # 80% purple
2175  tracer7bt.grid(row=3, column=2, columnspan=1, sticky=W)
2176  #
2177  gridbt = Button(Colorframe1, text="COLORgrid", style="W16.TButton", command=SetColorGrid ) #COLORgrid = "#808080" # 50% Gray
2178  gridbt.grid(row=4, column=0, columnspan=1, sticky=W)
2179  zerolinebt = Button(Colorframe1, text="COLORzeroline", style="ZLW16.TButton", command=SetColorZLine ) #COLORzeroline = "#0000ff" # 100% blue
2180  zerolinebt.grid(row=4, column=1, columnspan=1, sticky=W)
2181  ctriggerbt = Button(Colorframe1, text="COLORtrigger", style="TGW16.TButton", command=SetColorTrig ) #COLORtrigger = "#ff0000" # 100% red
2182  ctriggerbt.grid(row=4, column=2, columnspan=1, sticky=W)
2183  #
2184  ctextbt = Button(Colorframe1, text="COLORtext", style="W16.TButton", command=SetColorText ) #COLORtext = "#ffffff" # 100% white
2185  ctextbt.grid(row=4, column=3, columnspan=1, sticky=W)
2186  #
2187  cdismissbt = Button(Colorframe1, text="Dismiss", style="W16.TButton", command=DestroyColorScreen )
2188  cdismissbt.grid(row=5, column=0, columnspan=1, sticky=W)
2189  cresetbt = Button(Colorframe1, text="Reset Colors", style="W16.TButton", command=ResetAllColors )
2190  cresetbt.grid(row=5, column=1, columnspan=1, sticky=W)
2191 
2193  global ColorScreenStatus, ColorWindow
2194 
2195  if ColorScreenStatus.get() == 1:
2196  ColorScreenStatus.set(0)
2197  ColorWindow.destroy()
2198 
2200  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
2201  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
2202  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
2203 
2204  ResetColors()
2205  root.style.configure("T1W16.TButton", background=COLORtrace1)
2206  root.style.configure("Rtrace1.TButton", background=COLORtrace1)
2207  root.style.configure("Strace1.TButton", background=COLORtrace1)
2208  root.style.configure("Ctrace1.TButton", background=COLORtrace1)
2209  root.style.configure("Strace1.TCheckbutton", background=COLORtrace1)
2210  root.style.configure("T2W16.TButton", background=COLORtrace2)
2211  root.style.configure("Rtrace2.TButton", background=COLORtrace2)
2212  root.style.configure("Strace2.TButton", background=COLORtrace2)
2213  root.style.configure("Ctrace2.TButton", background=COLORtrace2)
2214  root.style.configure("Strace2.TCheckbutton", background=COLORtrace2)
2215  root.style.configure("T3W16.TButton", background=COLORtrace3)
2216  root.style.configure("Rtrace3.TButton", background=COLORtrace3)
2217  root.style.configure("Strace3.TButton", background=COLORtrace3)
2218  root.style.configure("Ctrace3.TButton", background=COLORtrace3)
2219  root.style.configure("Strace3.TCheckbutton", background=COLORtrace3)
2220  root.style.configure("T4W16.TButton", background=COLORtrace4)
2221  root.style.configure("Rtrace4.TButton", background=COLORtrace4)
2222  root.style.configure("Strace4.TButton", background=COLORtrace4)
2223  root.style.configure("Ctrace4.TButton", background=COLORtrace4)
2224  root.style.configure("Strace4.TCheckbutton", background=COLORtrace4)
2225  root.style.configure("T5W16.TButton", background=COLORtrace5)
2226  root.style.configure("T6W16.TButton", background=COLORtrace6)
2227  root.style.configure("Rtrace6.TButton", background=COLORtrace6)
2228  root.style.configure("Strace6.TButton", background=COLORtrace6)
2229  root.style.configure("Strace6.TCheckbutton", background=COLORtrace6)
2230  root.style.configure("T7W16.TButton", background=COLORtrace7)
2231  root.style.configure("Rtrace7.TButton", background=COLORtrace7)
2232  root.style.configure("Strace7.TButton", background=COLORtrace7)
2233  root.style.configure("Strace7.TCheckbutton", background=COLORtrace7)
2234  root.style.configure("TR1W16.TButton", background=COLORtraceR1)
2235  root.style.configure("TR2W16.TButton", background=COLORtraceR2)
2236  root.style.configure("TR3W16.TButton", background=COLORtraceR3)
2237  root.style.configure("TR4W16.TButton", background=COLORtraceR4)
2238  root.style.configure("TR5W16.TButton", background=COLORtraceR6)
2239  root.style.configure("TR6W16.TButton", background=COLORtraceR5)
2240  root.style.configure("TR5W16.TButton", background=COLORtraceR7)
2241  root.style.configure("TGW16.TButton", background=COLORtrigger)
2242 
2244  global COLORtrace1
2245 
2246  tempwindow = Tk()
2247  tempwindow.state("withdrawn")
2248  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace1", initialcolor=(COLORtrace1))
2249  tempwindow.destroy()
2250  if hexcolor != None:
2251  COLORtrace1 = str(hexcolor) # hexcolor
2252  root.style.configure("T1W16.TButton", background=COLORtrace1)
2253  root.style.configure("Rtrace1.TButton", background=COLORtrace1)
2254  root.style.configure("Strace1.TButton", background=COLORtrace1)
2255  root.style.configure("Ctrace1.TButton", background=COLORtrace1)
2256  root.style.configure("Strace1.TCheckbutton", background=COLORtrace1)
2257 
2259  global COLORtrace2
2260 
2261  tempwindow = Tk()
2262  tempwindow.state("withdrawn")
2263  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace2", initialcolor=(COLORtrace2))
2264  tempwindow.destroy()
2265  if hexcolor != None:
2266  COLORtrace2 = str(hexcolor) # hexcolor
2267  root.style.configure("T2W16.TButton", background=COLORtrace2)
2268  root.style.configure("Rtrace2.TButton", background=COLORtrace2)
2269  root.style.configure("Strace2.TButton", background=COLORtrace2)
2270  root.style.configure("Ctrace2.TButton", background=COLORtrace2)
2271  root.style.configure("Strace2.TCheckbutton", background=COLORtrace2)
2272 
2274  global COLORtrace3
2275 
2276  tempwindow = Tk()
2277  tempwindow.state("withdrawn")
2278  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace3", initialcolor=(COLORtrace3))
2279  tempwindow.destroy()
2280  if hexcolor != None:
2281  COLORtrace3 = str(hexcolor) # hexcolor
2282  root.style.configure("T3W16.TButton", background=COLORtrace3)
2283  root.style.configure("Rtrace3.TButton", background=COLORtrace3)
2284  root.style.configure("Strace3.TButton", background=COLORtrace3)
2285  root.style.configure("Ctrace3.TButton", background=COLORtrace3)
2286  root.style.configure("Strace3.TCheckbutton", background=COLORtrace3)
2287 
2289  global COLORtrace4
2290 
2291  tempwindow = Tk()
2292  tempwindow.state("withdrawn")
2293  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace4", initialcolor=(COLORtrace4))
2294  tempwindow.destroy()
2295  if hexcolor != None:
2296  COLORtrace4 = str(hexcolor) # hexcolor
2297  root.style.configure("T4W16.TButton", background=COLORtrace4)
2298  root.style.configure("Rtrace4.TButton", background=COLORtrace4)
2299  root.style.configure("Strace4.TButton", background=COLORtrace4)
2300  root.style.configure("Ctrace4.TButton", background=COLORtrace4)
2301  root.style.configure("Strace4.TCheckbutton", background=COLORtrace4)
2302 
2304  global COLORtrace5
2305 
2306  tempwindow = Tk()
2307  tempwindow.state("withdrawn")
2308  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace5", initialcolor=(COLORtrace5))
2309  tempwindow.destroy()
2310  if hexcolor != None:
2311  COLORtrace5 = str(hexcolor) # hexcolor
2312  root.style.configure("T5W16.TButton", background=COLORtrace5)
2313 
2315  global COLORtrace6
2316 
2317  tempwindow = Tk()
2318  tempwindow.state("withdrawn")
2319  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace6", initialcolor=(COLORtrace6))
2320  tempwindow.destroy()
2321  if hexcolor != None:
2322  COLORtrace6 = str(hexcolor) # hexcolor
2323  root.style.configure("T6W16.TButton", background=COLORtrace6)
2324  root.style.configure("Rtrace6.TButton", background=COLORtrace6)
2325  root.style.configure("Strace6.TButton", background=COLORtrace6)
2326  root.style.configure("Strace6.TCheckbutton", background=COLORtrace6)
2327 
2329  global COLORtrace7
2330 
2331  tempwindow = Tk()
2332  tempwindow.state("withdrawn")
2333  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace7", initialcolor=(COLORtrace7))
2334  tempwindow.destroy()
2335  if hexcolor != None:
2336  COLORtrace7 = str(hexcolor) # hexcolor
2337  root.style.configure("T7W16.TButton", background=COLORtrace7)
2338  root.style.configure("Rtrace7.TButton", background=COLORtrace7)
2339  root.style.configure("Strace7.TButton", background=COLORtrace7)
2340  root.style.configure("Strace7.TCheckbutton", background=COLORtrace7)
2341 
2343  global COLORtraceR1
2344 
2345  tempwindow = Tk()
2346  tempwindow.state("withdrawn")
2347  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR1", initialcolor=(COLORtraceR1))
2348  tempwindow.destroy()
2349  if hexcolor != None:
2350  COLORtraceR1 = str(hexcolor) # hexcolor
2351  root.style.configure("TR1W16.TButton", background=COLORtraceR1)
2352 
2354  global COLORtraceR2
2355 
2356  tempwindow = Tk()
2357  tempwindow.state("withdrawn")
2358  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR2", initialcolor=(COLORtraceR2))
2359  tempwindow.destroy()
2360  if hexcolor != None:
2361  COLORtraceR2 = str(hexcolor) # hexcolor
2362  root.style.configure("TR2W16.TButton", background=COLORtraceR2)
2363 
2365  global COLORtraceR3
2366 
2367  tempwindow = Tk()
2368  tempwindow.state("withdrawn")
2369  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR3", initialcolor=(COLORtraceR3))
2370  tempwindow.destroy()
2371  if hexcolor != None:
2372  COLORtraceR3 = str(hexcolor) # hexcolor
2373  root.style.configure("TR3W16.TButton", background=COLORtraceR3)
2374 
2376  global COLORtraceR4
2377 
2378  tempwindow = Tk()
2379  tempwindow.state("withdrawn")
2380  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR4", initialcolor=(COLORtraceR4))
2381  tempwindow.destroy()
2382  if hexcolor != None:
2383  COLORtraceR4 = str(hexcolor) # hexcolor
2384  root.style.configure("TR4W16.TButton", background=COLORtraceR4)
2385 
2387  global COLORtraceR5
2388 
2389  tempwindow = Tk()
2390  tempwindow.state("withdrawn")
2391  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR5", initialcolor=(COLORtraceR5))
2392  tempwindow.destroy()
2393  if hexcolor != None:
2394  COLORtraceR5 = str(hexcolor) # hexcolor
2395  root.style.configure("TR5W16.TButton", background=COLORtraceR5)
2396 
2398  global COLORtraceR6
2399 
2400  tempwindow = Tk()
2401  tempwindow.state("withdrawn")
2402  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR6", initialcolor=(COLORtraceR6))
2403  tempwindow.destroy()
2404  if hexcolor != None:
2405  COLORtraceR6 = str(hexcolor) # hexcolor
2406  root.style.configure("TR6W16.TButton", background=COLORtraceR6)
2407 
2409  global COLORtraceR7
2410 
2411  tempwindow = Tk()
2412  tempwindow.state("withdrawn")
2413  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR7", initialcolor=(COLORtraceR7))
2414  tempwindow.destroy()
2415  if hexcolor != None:
2416  COLORtraceR7 = str(hexcolor) # hexcolor
2417  root.style.configure("TR7W16.TButton", background=COLORtraceR7)
2418 
2420  global COLORgrid
2421 
2422  tempwindow = Tk()
2423  tempwindow.state("withdrawn")
2424  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORgrid", initialcolor=(COLORgrid))
2425  tempwindow.destroy()
2426  if hexcolor != None:
2427  COLORgrid = str(hexcolor) # hexcolor
2428 
2430  global COLORtext
2431 
2432  tempwindow = Tk()
2433  tempwindow.state("withdrawn")
2434  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtext", initialcolor=(COLORtext))
2435  tempwindow.destroy()
2436  if hexcolor != None:
2437  COLORtext = str(hexcolor) # hexcolor
2438 
2440  global COLORtrigger
2441 
2442  tempwindow = Tk()
2443  tempwindow.state("withdrawn")
2444  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrigger", initialcolor=(COLORtrigger))
2445  tempwindow.destroy()
2446  if hexcolor != None:
2447  COLORtrigger = str(hexcolor) # hexcolor
2448  root.style.configure("TGW16.TButton", background=COLORtrigger)
2449 
2451  global COLORzeroline
2452 
2453  tempwindow = Tk()
2454  tempwindow.state("withdrawn")
2455  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORzeroline", initialcolor=(COLORzeroline))
2456  tempwindow.destroy()
2457  if hexcolor != None:
2458  COLORzeroline = str(hexcolor) # hexcolor
2459  root.style.configure("ZLW16.TButton", background=COLORzeroline)
2460 #
2461 
2462 def BSaveScreen():
2463  global CANVASwidth, CANVASheight
2464  global COLORtext, MarkerNum, ColorMode
2465  # ask for file name
2466  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")])
2467  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n")
2468  if MarkerNum > 0 or ColorMode.get() > 0:
2469  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2470  else: # temp chnage text corlor to black
2471  COLORtext = "#000000"
2473  # first save postscript file
2474  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2475  # now convert to bit map
2476  # img = Image.open("screen_shot.eps")
2477  # img.save("screen_shot.gif", "gif")
2478  COLORtext = "#ffffff"
2480 
2481 def BSaveScreenXY():
2482  global CANVASwidthXY, CANVASheightXY, xywindow
2483  global COLORtext, MarkerNum, ColorMode, XYca
2484  # ask for file name
2485  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=xywindow)
2486  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=xywindow)
2487  if MarkerNum > 0 or ColorMode.get() > 0:
2488  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2489  else: # temp chnage text corlor to black
2490  COLORtext = "#000000"
2491  UpdateXYScreen()
2492  # first save postscript file
2493  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2494  # now convert to bit map
2495  # img = Image.open("screen_shot.eps")
2496  # img.save("screen_shot.gif", "gif")
2497  COLORtext = "#ffffff"
2498  UpdateXYScreen()
2499 
2500 def BSaveScreenIA():
2501  global CANVASwidthIA, CANVASheightIA
2502  global COLORtext, IAca, ColorMode, iawindow
2503  # ask for file name
2504  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=iawindow)
2505  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=iawindow)
2506  if ColorMode.get() > 0:
2507  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2508  else: # temp change text color to black for Black BG
2509  COLORtext = "#000000"
2510  UpdateIAScreen()
2511  # save postscript file
2512  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2513  #
2514  COLORtext = "#ffffff"
2515  UpdateIAScreen()
2516 
2517 def BSaveScreenBP():
2518  global CANVASwidthBP, CANVASheightBP
2519  global COLORtext, Bodeca, bodewindow
2520  # ask for file name
2521  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent = bodewindow)
2522  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=bodewindow)
2523  if MarkerNum > 0 or ColorMode.get() > 0:
2524  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2525  else: # temp change text color to black
2526  COLORtext = "#000000"
2528  # save postscript file
2529  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2530  #
2531  COLORtext = "#ffffff"
2533 
2534 def BSaveData():
2535  global VBuffA, VBuffB, IBuffA, IBuffB, SAMPLErate
2536 
2537  # open file to save data
2538  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2539  DataFile = open(filename, 'w')
2540  DataFile.write( 'Sample-#, CA-V, CA-I, CB-V, CB-I \n' )
2541  for index in range(len(VBuffA)):
2542  if Roll_Mode.get() > 0:
2543  TimePnt = float(index+0.0)
2544  else:
2545  TimePnt = float((index+0.0)/SAMPLErate)
2546  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + ', ' + str(IBuffA[index]) + ', '
2547  + str(VBuffB[index]) + ', ' + str(IBuffB[index]) + '\n')
2548  DataFile.close()
2549 
2550 def BSaveMuxData():
2551  global SAMPLErate, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2552  # open file to save data
2553  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2554  DataFile = open(filename, 'w')
2555  DataFile.write( 'Sample-#, MuxA, MuxB, MuxC, MuxD \n' )
2556 
2557  for index in range(len(VBuffMA)):
2558  TimePnt = float((index+0.0)/SAMPLErate)
2559  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + ', ' + str(VBuffMB[index]) + ', '
2560  + str(VBuffMC[index]) + ', ' + str(VBuffMD[index]) + '\n')
2561  DataFile.close()
2562 
2563 
2564 def BSaveChannelData():
2565  global SAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2566 
2567  # ask user for channel to save
2568  Channel = askstring("Choose Channel", "CA-V, CB-V, CA-I, CB-I\n MuxA, MuxB, MuxC, MuxD \n Channel:\n", initialvalue="CA-V")
2569  if (Channel == None): # If Cancel pressed, then None
2570  return
2571  # open file to save data
2572  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2573  DataFile = open(filename, 'w')
2574  if Channel == "CA-V":
2575  DataFile.write( 'Sample-#, CA-V\n' )
2576  for index in range(len(VBuffA)):
2577  TimePnt = float((index+0.0)/SAMPLErate)
2578  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + '\n')
2579  elif Channel == "CA-I":
2580  DataFile.write( 'Sample-#, CA-I,\n' )
2581  for index in range(len(IBuffA)):
2582  TimePnt = float((index+0.0)/SAMPLErate)
2583  DataFile.write( str(TimePnt) + ', ' + str(IBuffA[index]) + '\n')
2584  elif Channel == "CB-V":
2585  DataFile.write( 'Sample-#, CB-V\n' )
2586  for index in range(len(VBuffB)):
2587  TimePnt = float((index+0.0)/SAMPLErate)
2588  DataFile.write( str(TimePnt) + ', ' + str(VBuffB[index]) + '\n')
2589  elif Channel == "CB-I":
2590  DataFile.write( 'Sample-#, CB-I,\n' )
2591  for index in range(len(IBuffB)):
2592  TimePnt = float((index+0.0)/SAMPLErate)
2593  DataFile.write( str(TimePnt) + ', ' + str(IBuffB[index]) + '\n')
2594  elif Channel == "MuxA":
2595  DataFile.write( 'Sample-#, MuxA\n' )
2596  for index in range(len(VBuffMA)):
2597  TimePnt = float((index+0.0)/SAMPLErate)
2598  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + '\n')
2599  elif Channel == "MuxB":
2600  DataFile.write( 'Sample-#, MuxB\n' )
2601  for index in range(len(VBuffMB)):
2602  TimePnt = float((index+0.0)/SAMPLErate)
2603  DataFile.write( str(TimePnt) + ', ' + str(VBuffMB[index]) + '\n')
2604  elif Channel == "MuxC":
2605  DataFile.write( 'Sample-#, MuxC\n' )
2606  for index in range(len(VBuffMC)):
2607  TimePnt = float((index+0.0)/SAMPLErate)
2608  DataFile.write( str(TimePnt) + ', ' + str(VBuffMC[index]) + '\n')
2609  elif Channel == "MuxD":
2610  DataFile.write( 'Sample-#, MuxD\n' )
2611  for index in range(len(VBuffMD)):
2612  TimePnt = float((index+0.0)/SAMPLErate)
2613  DataFile.write( str(TimePnt) + ', ' + str(VBuffMD[index]) + '\n')
2614  DataFile.close()
2615 # place text string on clipboard
2616 def BSaveToClipBoard(TempBuffer):
2617  global VBuffA, VBuffB, IBuffA, IBuffB, VBuffMA, VBuffMB, VBuffMC, VBuffMD, SAMPLErate
2618 
2619  root.clipboard_clear()
2620  for index in range(len(TempBuffer)):
2621  root.clipboard_append(str(TempBuffer[index])+ '\n')
2622  root.update()
2623 
2624 # Get text string from clipboard
2625 def BReadFromClipboard():
2626 
2627  TempBuffer = []
2628  try:
2629  clip_text = root.clipboard_get()
2630  TempBuffer = numpy.fromstring( clip_text, dtype=float, sep='\n' )
2631  return(TempBuffer)
2632  except:
2633  return(TempBuffer)
2634 
2635 def BLoadDFiltAClip():
2636  global DFiltACoef
2637 
2638  DFiltACoef = BReadFromClipboard()
2639  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
2640 
2641 def BLoadDFiltBClip():
2642  global DFiltBCoef
2643 
2644  DFiltBCoef = BReadFromClipboard()
2645  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
2646 
2647 def BLoadAWGAFiltClip():
2648  global AWGFiltACoef
2649 
2650  AWGFiltACoef = BReadFromClipboard()
2651  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
2652 
2653 def BLoadAWGBFiltClip():
2654  global AWGFiltBCoef
2655 
2656  AWGFiltBCoef = BReadFromClipboard()
2657  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
2658 
2659 
2660 def BReadData():
2661  global VBuffA, VBuffB, IBuffA, IBuffB, SHOWsamples
2662 
2663  # Read values from CVS file
2664  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")])
2665  try:
2666  CSVFile = open(filename)
2667  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
2668  CSVFile.seek(0)
2669  csv_f = csv.reader(CSVFile, dialect)
2670  VBuffA = []
2671  VBuffB = []
2672  IBuffA = []
2673  IBuffB = []
2674  SHOWsamples = 0
2675  for row in csv_f:
2676  try:
2677  VBuffA.append(float(row[1]))
2678  IBuffA.append(float(row[2]))
2679  VBuffB.append(float(row[3]))
2680  IBuffB.append(float(row[4]))
2681  SHOWsamples = SHOWsamples + 1
2682  except:
2683  print( 'skipping non-numeric row')
2684  VBuffA = numpy.array(VBuffA)
2685  IBuffA = numpy.array(IBuffA)
2686  VBuffB = numpy.array(VBuffB)
2687  IBuffB = numpy.array(IBuffB)
2688  CSVFile.close()
2689  UpdateTimeTrace()
2690  except:
2691  showwarning("WARNING","No such file found or wrong format!")
2692 
2694 def BHelp():
2695 
2696  url = "https://wiki.analog.com/university/tools/m1k/alice/desk-top-users-guide"
2697  webbrowser.open(url,new=2)
2698 
2699 def BAbout():
2700  global RevDate, SWRev, FWRevOne, HWRevOne, DevID, Version_url
2701 #Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.8/alice-desktop-1.3-setup.exe'
2702  try:
2703  if sys.version_info[0] == 2:
2704  u = urllib2.urlopen(Version_url)
2705  if sys.version_info[0] == 3:
2706  u = urllib.request.urlopen(Version_url)
2707  meta = u.info()
2708  time_string = str(meta.getheaders("Last-Modified"))
2709  except:
2710  time_string = "Unavailable"
2711  showinfo("About ALICE", "ALICE DeskTop" + SWRev + RevDate + "\n" +
2712  "Last Released Version: " + time_string[7:18] + "\n" +
2713  "ADALM1000 Hardware Rev " + str(HWRevOne) + "\n" +
2714  "Firmware Rev " + str(FWRevOne) + "\n" +
2715  "Board Serial Number " + DevID + "\n" +
2716  "Software is provided as is without any Warranty")
2717 #
2718 
2719 def BSnapShot():
2720  global T1Vline, T2Vline, T1Iline, T2Iline
2721  global Tmathline, TMRline, TXYRline
2722  global T1VRline, T2VRline, T1IRline, T2IRline, TMCVline, TMDVline
2723  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowMath, MathTrace
2724  global MuxScreenStatus, TMARline, TMBRline, TMCRline, TMDRline
2725  global TMAVline, TMBVline, TMCVline, TMDVline
2726  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb
2727  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
2728 
2729  if ShowC1_V.get() == 1:
2730  T1VRline = T1Vline # V reference Trace line channel A
2731  if ShowC2_V.get() == 1:
2732  T2VRline = T2Vline # V reference Trace line channel B
2733  if ShowC1_I.get() == 1:
2734  T1IRline = T1Iline # I reference Trace line channel A
2735  if ShowC2_I.get() == 1:
2736  T2IRline = T2Iline # I reference Trace line channel B
2737  if MathTrace.get() > 0:
2738  TMRline = Tmathline # Math reference Trace line
2739  if MuxScreenStatus.get() > 0:
2740  if Show_CBA.get() > 0:
2741  TMARline = TMAVline # V reference Trace line Mux channel A
2742  if Show_CBB.get() > 0:
2743  TMBRline = TMBVline # V reference Trace line Mux channel B
2744  if Show_CBC.get() > 0:
2745  TMCRline = TMCVline # V reference Trace line Mux channel C
2746  if Show_CBD.get() > 0:
2747  TMDRline = TMDVline # V reference Trace line Mux channel D
2748 #
2749 
2750 def BSnapShotXY():
2751  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY
2752  global XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
2753 
2754  if len(XYlineVA) > 4:
2755  XYRlineVA = XYlineVA
2756  if len(XYlineVB) > 4:
2757  XYRlineVB = XYlineVB
2758  if len(XYlineIA) > 4:
2759  XYRlineIA = XYlineIA
2760  if len(XYlineIB) > 4:
2761  XYRlineIB = XYlineIB
2762  if len(XYlineM) > 4:
2763  XYRlineM = XYlineM
2764  if len(XYlineMX) > 4:
2765  XYRlineMX = XYlineMX
2766  if len(XYlineMY) > 4:
2767  XYRlineMY = XYlineMY
2768 #
2769 
2770 def BSaveCal():
2771  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2772  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2773  global DevID
2774  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2775  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2776  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2777  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2778 
2779  devidstr = DevID[17:31]
2780  filename = devidstr + "_O.cal"
2781  CalFile = open(filename, "w")
2782  #
2783  CalFile.write('CHAVGainEntry.delete(0,END)\n')
2784  CalFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
2785  CalFile.write('CHBVGainEntry.delete(0,END)\n')
2786  CalFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
2787  CalFile.write('CHAVOffsetEntry.delete(0,END)\n')
2788  CalFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
2789  CalFile.write('CHBVOffsetEntry.delete(0,END)\n')
2790  CalFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
2791  #
2792  CalFile.write('CHAIGainEntry.delete(0,END)\n')
2793  CalFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
2794  CalFile.write('CHBIGainEntry.delete(0,END)\n')
2795  CalFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
2796  CalFile.write('CHAIOffsetEntry.delete(0,END)\n')
2797  CalFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
2798  CalFile.write('CHBIOffsetEntry.delete(0,END)\n')
2799  CalFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
2800  #
2801  # save channel AC frequency compensation settings
2802  try:
2803  CHA_TC1.set(float(cha_TC1Entry.get()))
2804  CHA_TC2.set(float(cha_TC2Entry.get()))
2805  CHB_TC1.set(float(chb_TC1Entry.get()))
2806  CHB_TC2.set(float(chb_TC2Entry.get()))
2807  CHA_A1.set(float(cha_A1Entry.get()))
2808  CHA_A2.set(float(cha_A2Entry.get()))
2809  CHB_A1.set(float(chb_A1Entry.get()))
2810  CHB_A2.set(float(chb_A2Entry.get()))
2811  except:
2812  donothing()
2813  CalFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
2814  CalFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
2815  CalFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
2816  CalFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
2817  CalFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
2818  CalFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
2819  CalFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
2820  CalFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
2821  CalFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
2822  CalFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
2823  CalFile.write('cha_TC1Entry.delete(0,END)\n')
2824  CalFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
2825  CalFile.write('cha_TC2Entry.delete(0,END)\n')
2826  CalFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
2827  CalFile.write('chb_TC1Entry.delete(0,END)\n')
2828  CalFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
2829  CalFile.write('chb_TC2Entry.delete(0,END)\n')
2830  CalFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
2831  CalFile.write('cha_A1Entry.delete(0,END)\n')
2832  CalFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
2833  CalFile.write('cha_A2Entry.delete(0,END)\n')
2834  CalFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
2835  CalFile.write('chb_A1Entry.delete(0,END)\n')
2836  CalFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
2837  CalFile.write('chb_A2Entry.delete(0,END)\n')
2838  CalFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
2839 
2840  CalFile.close()
2841 
2842 def BLoadCal():
2843  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2844  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2845  global DevID
2846  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2847  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2848  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2849  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2850 
2851  devidstr = DevID[17:31]
2852  filename = devidstr + "_O.cal"
2853  try:
2854  CalFile = open(filename)
2855  for line in CalFile:
2856  exec( line.rstrip() )
2857  CalFile.close()
2858  except:
2859  print( "Cal file for this device not found")
2860 
2861 def BUserAMeas():
2862  global UserAString, UserALabel, MeasUserA
2863 
2864  TempString = UserALabel
2865  UserALabel = askstring("Measurement Label", "Current Label: " + UserALabel + "\n\nNew Label:\n", initialvalue=UserALabel)
2866  if (UserALabel == None): # If Cancel pressed, then None
2867  MeasUserA.set(0)
2868  UserALabel = TempString
2869  return
2870  TempString = UserAString
2871  UserAString = askstring("Measurement Formula", "Current Formula: " + UserAString + "\n\nNew Formula:\n", initialvalue=UserAString)
2872  if (UserAString == None): # If Cancel pressed, then None
2873  MeasUserA.set(0)
2874  UserAString = TempString
2875  return
2876  MeasUserA.set(1)
2877 
2878 def BUserBMeas():
2879  global UserBString, UserBLabel, MeasUserB
2880 
2881  TempString = UserBLabel
2882  UserBLabel = askstring("Measurement Label", "Current Label: " + UserBLabel + "\n\nNew Label:\n", initialvalue=UserBLabel)
2883  if (UserBLabel == None): # If Cancel pressed, then None
2884  MeasUserB.set(0)
2885  UserBLabel = TempString
2886  return
2887  TempString = UserBString
2888  UserBString = askstring("Measurement Formula", "Current Formula: " + UserBString + "\n\nNew Formula:\n", initialvalue=UserBString)
2889  if (UserBString == None): # If Cancel pressed, then None
2890  MeasUserB.set(0)
2891  UserBString = TempString
2892  return
2893  MeasUserB.set(1)
2894 #
2895 
2896 def BUserCustomPlotText():
2897  global LabelPlotText, PlotLabelText # = "Custom Plot Label"
2898 
2899  TempString = PlotLabelText
2900  PlotLabelText = askstring("Custom Label", "Current Plot Label: " + PlotLabelText + "\n\nNew Label:\n", initialvalue=PlotLabelText)
2901  if (PlotLabelText == None): # If Cancel pressed, then None
2902  LabelPlotText.set(0)
2903  PlotLabelText = TempString
2904  return
2905  LabelPlotText.set(1)
2906 
2907 def NewEnterMathControls():
2908  global RUNstatus, MathScreenStatus, MathWindow, SWRev, RevDate
2909  global MathString, MathUnits, MathXString, MathXUnits, MathYString, MathYUnits
2910  global MathAxis, MathXAxis, MathYAxis, MathTrace
2911  global formentry, unitsentry, axisentry, xformentry, xunitsentry, xaxisentry, yformentry, yunitsentry, yaxisentry
2912  global formlab, xformlab, yformlab, FrameBG
2913  global Mframe1, Mframe2, Mframe3, Mframe4
2914 
2915  if MathScreenStatus.get() == 0:
2916  MathScreenStatus.set(1)
2917  #
2918  MathWindow = Toplevel()
2919  MathWindow.title("Math Formula " + SWRev + RevDate)
2920  MathWindow.resizable(FALSE,FALSE)
2921  MathWindow.protocol("WM_DELETE_WINDOW", DestroyMathScreen)
2922  MathWindow.configure(background=FrameBG)
2923  Mframe1 = LabelFrame(MathWindow, text="Built-in Exp", style="A10T5.TLabelframe") #"A10T5.TLabelframe")
2924  Mframe2 = LabelFrame(MathWindow, text="Math Trace", style="A10T5.TLabelframe")
2925  Mframe3 = LabelFrame(MathWindow, text="X Math Trace", style="A10T6.TLabelframe")
2926  Mframe4 = LabelFrame(MathWindow, text="Y Math Trace", style="A10T7.TLabelframe")
2927  # frame1.grid(row=0, column=0, sticky=W)
2928  #
2929  Mframe1.grid(row = 0, column=0, rowspan=3, sticky=W)
2930  Mframe2.grid(row = 0, column=1, sticky=W)
2931  Mframe3.grid(row = 1, column=1, sticky=W)
2932  Mframe4.grid(row = 2, column=1, sticky=W)
2933  #
2934  # Built in functions
2935  #
2936  mrb1 = Radiobutton(Mframe1, text='none', variable=MathTrace, value=0, command=UpdateTimeTrace)
2937  mrb1.grid(row=0, column=0, sticky=W)
2938  mrb2 = Radiobutton(Mframe1, text='CAV+CBV', variable=MathTrace, value=1, command=UpdateTimeTrace)
2939  mrb2.grid(row=1, column=0, sticky=W)
2940  mrb3 = Radiobutton(Mframe1, text='CAV-CBV', variable=MathTrace, value=2, command=UpdateTimeTrace)
2941  mrb3.grid(row=2, column=0, sticky=W)
2942  mrb4 = Radiobutton(Mframe1, text='CBV-CAV', variable=MathTrace, value=3, command=UpdateTimeTrace)
2943  mrb4.grid(row=3, column=0, sticky=W)
2944  mrb5 = Radiobutton(Mframe1, text='CAI-CBI', variable=MathTrace, value=8, command=UpdateTimeTrace)
2945  mrb5.grid(row=4, column=0, sticky=W)
2946  mrb6 = Radiobutton(Mframe1, text='CBI-CAI', variable=MathTrace, value=9, command=UpdateTimeTrace)
2947  mrb6.grid(row=5, column=0, sticky=W)
2948  mrb7 = Radiobutton(Mframe1, text='CAV*CAI', variable=MathTrace, value=4, command=UpdateTimeTrace)
2949  mrb7.grid(row=6, column=0, sticky=W)
2950  mrb8 = Radiobutton(Mframe1, text='CBV*CBI', variable=MathTrace, value=5, command=UpdateTimeTrace)
2951  mrb8.grid(row=7, column=0, sticky=W)
2952  mrb9 = Radiobutton(Mframe1, text='CAV/CAI', variable=MathTrace, value=6, command=UpdateTimeTrace)
2953  mrb9.grid(row=8, column=0, sticky=W)
2954  mrb10 = Radiobutton(Mframe1, text='CBV/CBI', variable=MathTrace, value=7, command=UpdateTimeTrace)
2955  mrb10.grid(row=9, column=0, sticky=W)
2956  mrb11 = Radiobutton(Mframe1, text='CBV/CAV', variable=MathTrace, value=10, command=UpdateTimeTrace)
2957  mrb11.grid(row=10, column=0, sticky=W)
2958  mrb12 = Radiobutton(Mframe1, text='CBI/CAI', variable=MathTrace, value=11, command=UpdateTimeTrace)
2959  mrb12.grid(row=11, column=0, sticky=W)
2960  mrb13 = Radiobutton(Mframe1, text='Formula', variable=MathTrace, value=12, command=UpdateTimeTrace)
2961  mrb13.grid(row=12, column=0, sticky=W)
2962  #
2963  # Math trace formula sub Mframe2
2964  #
2965  sframe2a = Frame( Mframe2 )
2966  sframe2a.pack(side=TOP)
2967  formlab = Label(sframe2a, text=" Formula ", style= "A10B.TLabel")
2968  formlab.pack(side=LEFT)
2969  formentry = Entry(sframe2a, width=23)
2970  formentry.pack(side=LEFT)
2971  formentry.delete(0,"end")
2972  formentry.insert(0,MathString)
2973  sframe2b = Frame( Mframe2 )
2974  sframe2b.pack(side=TOP)
2975  unitslab = Label(sframe2b, text="Units ", style= "A10B.TLabel")
2976  unitslab.pack(side=LEFT)
2977  unitsentry = Entry(sframe2b, width=6)
2978  unitsentry.pack(side=LEFT)
2979  unitsentry.delete(0,"end")
2980  unitsentry.insert(0,MathUnits)
2981  checkbt = Button(sframe2b, text="Check", command=CheckMathString )
2982  checkbt.pack(side=LEFT)
2983  sframe2c = Frame( Mframe2 )
2984  sframe2c.pack(side=TOP)
2985  axislab = Label(sframe2c, text="Axis ", style= "A10B.TLabel")
2986  axislab.pack(side=LEFT)
2987  axisentry = Entry(sframe2c, width=4)
2988  axisentry.pack(side=LEFT)
2989  axisentry.delete(0,"end")
2990  axisentry.insert(0,MathAxis)
2991  applybt = Button(sframe2c, text="Apply", command=ApplyMathString )
2992  applybt.pack(side=LEFT)
2993  #
2994  # X Math trace formula sub Mframe3
2995  #
2996  sframe3a = Frame( Mframe3 )
2997  sframe3a.pack(side=TOP)
2998  xformlab = Label(sframe3a, text="X Formula ", style= "A10B.TLabel")
2999  xformlab.pack(side=LEFT)
3000  xformentry = Entry(sframe3a, width=23)
3001  xformentry.pack(side=LEFT)
3002  xformentry.delete(0,"end")
3003  xformentry.insert(0, MathXString)
3004  sframe3b = Frame( Mframe3 )
3005  sframe3b.pack(side=TOP)
3006  xunitslab = Label(sframe3b, text="X Units ", style= "A10B.TLabel")
3007  xunitslab.pack(side=LEFT)
3008  xunitsentry = Entry(sframe3b, width=6)
3009  xunitsentry.pack(side=LEFT)
3010  xunitsentry.delete(0,"end")
3011  xunitsentry.insert(0, MathXUnits)
3012  xcheckbt = Button(sframe3b, text="Check", command=CheckMathXString )
3013  xcheckbt.pack(side=LEFT)
3014  sframe3c = Frame( Mframe3 )
3015  sframe3c.pack(side=TOP)
3016  xaxislab = Label(sframe3c, text="X Axis ", style= "A10B.TLabel")
3017  xaxislab.pack(side=LEFT)
3018  xaxisentry = Entry(sframe3c, width=4)
3019  xaxisentry.pack(side=LEFT)
3020  xaxisentry.delete(0,"end")
3021  xaxisentry.insert(0, MathXAxis)
3022  xapplybt = Button(sframe3c, text="Apply", command=ApplyMathXString )
3023  xapplybt.pack(side=LEFT)
3024  #
3025  # Math trace formula sub Mframe4
3026  #
3027  sframe4a = Frame( Mframe4 )
3028  sframe4a.pack(side=TOP)
3029  yformlab = Label(sframe4a, text="Y Formula ", style= "A10B.TLabel")
3030  yformlab.pack(side=LEFT)
3031  yformentry = Entry(sframe4a, width=23)
3032  yformentry.pack(side=LEFT)
3033  yformentry.delete(0,"end")
3034  yformentry.insert(0,MathYString)
3035  sframe4b = Frame( Mframe4 )
3036  sframe4b.pack(side=TOP)
3037  yunitslab = Label(sframe4b, text="Y Units ", style= "A10B.TLabel")
3038  yunitslab.pack(side=LEFT)
3039  yunitsentry = Entry(sframe4b, width=6)
3040  yunitsentry.pack(side=LEFT)
3041  yunitsentry.delete(0,"end")
3042  yunitsentry.insert(0,MathYUnits)
3043  ycheckbt = Button(sframe4b, text="Check", command=CheckMathYString )
3044  ycheckbt.pack(side=LEFT)
3045  sframe4c = Frame( Mframe4 )
3046  sframe4c.pack(side=TOP)
3047  yaxislab = Label(sframe4c, text="Y Axis ", style= "A10B.TLabel")
3048  yaxislab.pack(side=LEFT)
3049  yaxisentry = Entry(sframe4c, width=4)
3050  yaxisentry.pack(side=LEFT)
3051  yaxisentry.delete(0,"end")
3052  yaxisentry.insert(0,MathYAxis)
3053  yapplybt = Button(sframe4c, text="Apply", command=ApplyMathYString )
3054  yapplybt.pack(side=LEFT)
3055 
3056  dismissbutton = Button(MathWindow, text="Dismiss", command=DestroyMathScreen)
3057  dismissbutton.grid(row=3, column=0, sticky=W)
3058 
3059  if RUNstatus.get() > 0:
3060  UpdateTimeTrace()
3061 
3062 def DestroyMathScreen():
3063  global MathScreenStatus, MathWindow
3064 
3065  if MathScreenStatus.get() == 1:
3066  MathScreenStatus.set(0)
3067  MathWindow.destroy()
3068 
3069 def CheckMathString():
3070  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry, formlab
3071  global VBuffA, VBuffB, IBuffA, IBuffB
3072  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3073  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3074  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
3075  global FFTBuffA, FFTBuffB, FFTwindowshape
3076  global AWGAwaveform, AWGBwaveform
3077  global Show_MathX, Show_MathY
3078  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3079  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3080 
3081  t = 0
3082  TempString = formentry.get()
3083  try:
3084  MathResult = eval(TempString)
3085  formlab.configure(text="Formula ", style= "A10G.TLabel")
3086  except:
3087  formlab.configure(text="Formula ", style= "A10R.TLabel")
3088 
3089 def CheckMathXString():
3090  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry, xformlab
3091  global VBuffA, VBuffB, IBuffA, IBuffB
3092  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3093  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3094  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
3095  global FFTBuffA, FFTBuffB, FFTwindowshape
3096  global AWGAwaveform, AWGBwaveform
3097  global Show_MathX, Show_MathY
3098  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3099  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3100 
3101  t = 0
3102  TempString = xformentry.get()
3103  try:
3104  MathResult = eval(TempString)
3105  xformlab.configure(text="X Formula ", style= "A10G.TLabel")
3106  except:
3107  xformlab.configure(text="X Formula ", style= "A10R.TLabel")
3108 
3109 def CheckMathYString():
3110  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry, yformlab
3111  global VBuffA, VBuffB, IBuffA, IBuffB
3112  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3113  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3114  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
3115  global FFTBuffA, FFTBuffB, FFTwindowshape
3116  global AWGAwaveform, AWGBwaveform
3117  global Show_MathX, Show_MathY
3118  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3119  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3120 
3121  t = 0
3122  TempString = yformentry.get()
3123  try:
3124  MathResult = eval(TempString)
3125  yformlab.configure(text="Y Formula ", style= "A10G.TLabel")
3126  except:
3127  yformlab.configure(text="Y Formula ", style= "A10R.TLabel")
3128 
3129 def ApplyMathString():
3130  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry
3131 
3132  MathString = formentry.get()
3133  MathUnits = unitsentry.get()
3134  MathAxis = axisentry.get()
3135 
3136 def ApplyMathXString():
3137  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry
3138 
3139  MathXString = xformentry.get()
3140  MathXUnits = xunitsentry.get()
3141  MathXAxis = xaxisentry.get()
3142 
3143 def ApplyMathYString():
3144  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry
3145 
3146  MathYString = yformentry.get()
3147  MathYUnits = yunitsentry.get()
3148  MathYAxis = yaxisentry.get()
3149 
3150 def BSetMarkerLocation():
3151  global MarkerLoc, RUNstatus
3152 
3153  TempString = MarkerLoc
3154  MarkerLoc = askstring("Marker Text Location", "Current Marker Text Location: " + MarkerLoc + "\n\nNew Location: (UL, UR, LL, LR)\n", initialvalue=MarkerLoc)
3155  if (MarkerLoc == None): # If Cancel pressed, then None
3156  MarkerLoc = TempString
3157  if RUNstatus.get() == 0: # if not running
3158  UpdateTimeTrace() # Update
3159 
3160 def donothing():
3161  global RUNstatus
3162 
3163 def DoNothing(event):
3164  global RUNstatus
3165 
3166 def BShowCurvesAll():
3167  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
3168 
3169  ShowC1_V.set(1)
3170  ShowC1_I.set(1)
3171  ShowC2_V.set(1)
3172  ShowC2_I.set(1)
3173  if RUNstatus.get() == 0: # if not running
3174  UpdateTimeTrace() # Update
3175 
3176 def BShowCurvesNone():
3177  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
3178 
3179  ShowC1_V.set(0)
3180  ShowC1_I.set(0)
3181  ShowC2_V.set(0)
3182  ShowC2_I.set(0)
3183  if RUNstatus.get() == 0: # if not running
3184  UpdateTimeTrace() # Update
3185 
3186 def BTriggerEdge():
3187  global TgEdge
3188 
3189 # TRIGCOND trigcondRisingPositive = 0
3190 # TRIGCOND trigcondFallingNegative = 1
3191 
3192 def BTrigger50p():
3193  global TgInput, TRIGGERlevel, TRIGGERentry, RUNstatus
3194  global MaxV1, MinV1, MaxV2, MinV2
3195  global MaxI1, MinI1, MaxI2, MinI2
3196  global MidVMuxA, MidVMuxB, MidVMuxC, MidVMuxD
3197  global ChopMuxMode, ChopTrig
3198  # set new trigger level to mid point of waveform
3199  MidV1 = (MaxV1+MinV1)/2
3200  MidV2 = (MaxV2+MinV2)/2
3201  MidI1 = (MaxI1+MinI1)/2
3202  MidI2 = (MaxI2+MinI2)/2
3203  if (TgInput.get() == 0):
3204  DCString = "0.0"
3205  elif (TgInput.get() == 1 or TgInput.get() == 5):
3206  DCString = ' {0:.2f} '.format(MidV1)
3207  elif (TgInput.get() == 2 ):
3208  DCString = ' {0:.2f} '.format(MidI1)
3209  elif (TgInput.get() == 3 ):
3210  DCString = ' {0:.2f} '.format(MidV2)
3211  elif (TgInput.get() == 4 ):
3212  DCString = ' {0:.2f} '.format(MidI2)
3213 #
3214  if ChopMuxMode.get() > 0:
3215  if ChopTrig.get() == 0:
3216  DCString = "0.0"
3217  if ChopTrig.get() == 1:
3218  DCString = ' {0:.2f} '.format(MidVMuxA)
3219  if ChopTrig.get() == 2:
3220  DCString = ' {0:.2f} '.format(MidVMuxB)
3221  if ChopTrig.get() == 3:
3222  DCString = ' {0:.2f} '.format(MidVMuxC)
3223  if ChopTrig.get() == 4:
3224  DCString = ' {0:.2f} '.format(MidVMuxD)
3225 #
3226  TRIGGERlevel = eval(DCString)
3227  TRIGGERentry.delete(0,END)
3228  TRIGGERentry.insert(4, DCString)
3229  if RUNstatus.get() == 0: # if not running
3230  UpdateTimeTrace() # Update
3231 
3232 
3233 def BTriggerMode():
3234  global TgInput
3235 
3236 # if (TgInput.get() == 0):
3237  # no trigger
3238 # elif (TgInput.get() == 1):
3239  # trigger source set to detector of analog in channels
3240  # auto trigger timeout value
3241 # elif (TgInput.get() == 2):
3242  # trigger source set to detector of analog in channels
3243  # 0 disables auto trigger
3244 
3245 def BTriglevel(event):
3246  global TRIGGERlevel, TRIGGERentry, RUNstatus
3247 
3248  # evalute entry string to a numerical value
3249  try:
3250  TRIGGERlevel = float(eval(TRIGGERentry.get()))
3251  except:
3252  TRIGGERentry.delete(0,END)
3253  TRIGGERentry.insert(0, TRIGGERlevel)
3254  # set new trigger level
3255  if RUNstatus.get() == 0: # if not running
3256  UpdateTimeTrace() # Update
3257 
3258 
3259 def BHoldOff(event):
3260  global HoldOff, HoldOffentry, RUNstatus
3261 
3262  try:
3263  HoldOff = float(eval(HoldOffentry.get()))
3264  except:
3265  HoldOffentry.delete(0,END)
3266  HoldOffentry.insert(0, HoldOff)
3267  if RUNstatus.get() == 0: # if not running
3268  UpdateTimeTrace() # Update
3269 # Set Horx possition from entry widget
3270 def BHozPoss(event):
3271  global HozPoss, HozPossentry, RUNstatus
3272 
3273  try:
3274  HozPoss = float(eval(HozPossentry.get()))
3275  except:
3276  HozPossentry.delete(0,END)
3277  HozPossentry.insert(0, HozPoss)
3278  if RUNstatus.get() == 0: # if not running
3279  UpdateTimeTrace() # Update
3280 #
3281 def SetTriggerPoss():
3282  global HozPossentry, TgInput, TMsb
3283 
3284  # get time scale
3285  try:
3286  TIMEdiv = float(eval(TMsb.get()))
3287  except:
3288  TIMEdiv = 0.5
3289  TMsb.delete(0,"end")
3290  TMsb.insert(0,TIMEdiv)
3291  # prevent divide by zero error
3292  if TIMEdiv < 0.0002:
3293  TIMEdiv = 0.01
3294  if TgInput.get() > 0:
3295  HozPoss = -5 * TIMEdiv
3296  HozPossentry.delete(0,END)
3297  HozPossentry.insert(0, HozPoss)
3298 #
3299 def IncHoldOff():
3300  global HoldOffentry, HoldOff, TgInput, TMsb
3301 
3302 # get time scale
3303  try:
3304  TIMEdiv = float(eval(TMsb.get()))
3305  except:
3306  TIMEdiv = 0.5
3307  TMsb.delete(0,"end")
3308  TMsb.insert(0,TIMEdiv)
3309  # prevent divide by zero error
3310  if TIMEdiv < 0.0002:
3311  TIMEdiv = 0.01
3312  if TgInput.get() == 0:
3313  HoldOff = HoldOff + TIMEdiv
3314  HoldOffentry.delete(0,END)
3315  HoldOffentry.insert(0, HoldOff)
3316 
3317 def SetMuxAPoss():
3318  global CHB_APosEntry, DCVMuxA
3319 
3320  CHB_APosEntry.delete(0,"end")
3321  CHB_APosEntry.insert(0, ' {0:.2f} '.format(DCVMuxA))
3322 #
3323 def SetMuxBPoss():
3324  global CHB_BPosEntry, DCVMuxB
3325 
3326  CHB_BPosEntry.delete(0,"end")
3327  CHB_BPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxB))
3328 #
3329 def SetMuxCPoss():
3330  global CHB_CPosEntry, DCVMuxC
3331 
3332  CHB_CPosEntry.delete(0,"end")
3333  CHB_CPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxC))
3334 #
3335 def SetMuxDPoss():
3336  global CHD_BPosEntry, DCVMuxD
3337 
3338  CHB_DPosEntry.delete(0,"end")
3339  CHB_DPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxD))
3340 #
3341 def SetScaleMuxA():
3342  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
3343 
3344  if MarkerScale.get() != 1:
3345  MarkerScale.set(5)
3346  CHB_Alab.config(style="Rtrace2.TButton")
3347  CHB_Blab.config(style="Strace6.TButton")
3348  CHB_Clab.config(style="Strace7.TButton")
3349  CHB_Dlab.config(style="Strace4.TButton")
3350  else:
3351  MarkerScale.set(0)
3352 #
3353 def SetScaleMuxB():
3354  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
3355 
3356  if MarkerScale.get() != 1:
3357  MarkerScale.set(6)
3358  CHB_Alab.config(style="Strace2.TButton")
3359  CHB_Blab.config(style="Rtrace6.TButton")
3360  CHB_Clab.config(style="Strace7.TButton")
3361  CHB_Dlab.config(style="Strace4.TButton")
3362  else:
3363  MarkerScale.set(0)
3364 #
3365 def SetScaleMuxC():
3366  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
3367 
3368  if MarkerScale.get() != 1:
3369  MarkerScale.set(7)
3370  CHB_Alab.config(style="Strace2.TButton")
3371  CHB_Blab.config(style="Strace6.TButton")
3372  CHB_Clab.config(style="Rtrace7.TButton")
3373  CHB_Dlab.config(style="Strace4.TButton")
3374  else:
3375  MarkerScale.set(0)
3376 #
3377 def SetScaleMuxD():
3378  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
3379 
3380  if MarkerScale.get() != 1:
3381  MarkerScale.set(8)
3382  CHB_Alab.config(style="Strace2.TButton")
3383  CHB_Blab.config(style="Strace6.TButton")
3384  CHB_Clab.config(style="Strace7.TButton")
3385  CHB_Dlab.config(style="Rtrace4.TButton")
3386  else:
3387  MarkerScale.set(0)
3388 #
3389 def SetVAPoss():
3390  global CHAVPosEntry, DCV1
3391 
3392  CHAVPosEntry.delete(0,"end")
3393  CHAVPosEntry.insert(0, ' {0:.2f} '.format(DCV1))
3394 #
3395 def SetVBPoss():
3396  global CHBVPosEntry, DCV2
3397 
3398  CHBVPosEntry.delete(0,"end")
3399  CHBVPosEntry.insert(0, ' {0:.2f} '.format(DCV2))
3400 #
3401 def SetIAPoss():
3402  global CHAIPosEntry, DCI1
3403 
3404  CHAIPosEntry.delete(0,"end")
3405  CHAIPosEntry.insert(0, ' {0:.2f} '.format(DCI1))
3406 #
3407 def SetIBPoss():
3408  global CHBIPosEntry, DCI2
3409 
3410  CHBIPosEntry.delete(0,"end")
3411  CHBIPosEntry.insert(0, ' {0:.2f} '.format(DCI2))
3412 #
3413 def SetXYVAPoss():
3414  global CHAVPosEntryxy, DCV1
3415 
3416  CHAVPosEntryxy.delete(0,"end")
3417  CHAVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV1))
3418 #
3419 def SetXYVBPoss():
3420  global CHBVPosEntryxy, DCV2
3421 
3422  CHBVPosEntryxy.delete(0,"end")
3423  CHBVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV2))
3424 #
3425 def SetXYIAPoss():
3426  global CHAIPosEntryxy, DCI1
3427 
3428  CHAIPosEntryxy.delete(0,"end")
3429  CHAIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI1))
3430 #
3431 def SetXYIBPoss():
3432  global CHBIPosEntryxy, DCI2
3433 
3434  CHBIPosEntryxy.delete(0,"end")
3435  CHBIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI2))
3436 
3437 def Bcloseexit():
3438  global RUNstatus, session, CHA, CHB, devx, AWG_2X, Closed
3439 
3440  RUNstatus.set(0)
3441  Closed = 1
3442  # BSaveConfig("alice-last-config.cfg")
3443  try:
3444  # try to write last config file, Don't crash if running in Write protected space
3445  BSaveConfig("alice-last-config.cfg")
3446  # Put channels in Hi-Z and exit
3447  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
3448  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
3449  devx.set_adc_mux(0) # set ADC mux conf to default
3450  AWG_2X.set(0)
3451  BAWG2X()
3452  CHA.constant(0.0)
3453  CHB.constant(0.0)
3454  devx.set_led(0b001) # Set LED.red on the way out
3455  if session.continuous:
3456  session.end()
3457  except:
3458  donothing()
3459 
3460  root.destroy()
3461  exit()
3462 
3463 def BStart():
3464  global RUNstatus, PowerStatus, devx, PwrBt, DevID, FWRevOne, session, AWGSync
3465  global contloop, discontloop, TIMEdiv, First_Slow_sweep
3466  global TimeDisp, XYDisp, PhADisp, FreqDisp, BodeDisp, IADisp
3467  global Dlog_open, dlog, Ztime
3468 
3469  # Check if User wants data loging on or off
3470  if Dlog_open.get() == 1 and dlog.get() > 0:
3471  Ztime = time.time()
3472  elif Dlog_open.get() == 0 and dlog.get() > 0:
3473  DlogerOpen_out()
3474  Ztime = time.time()
3475  else:
3476  Dlog_open.set(0)
3477  #
3478  if DevID == "No Device":
3479  showwarning("WARNING","No Device Plugged In!")
3480  elif FWRevOne == 0.0:
3481  showwarning("WARNING","Out of data Firmware!")
3482  elif TimeDisp.get() == 0 and XYDisp.get() == 0 and PhADisp.get() == 0 and FreqDisp.get() == 0 and BodeDisp.get() == 0 and IADisp.get() == 0:
3483  showwarning("WARNING","Enable at least one Instrument!")
3484  else:
3485  if PowerStatus == 0:
3486  PowerStatus = 1
3487  PwrBt.config(style="Pwr.TButton",text="PWR-On")
3488  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
3489  if (RUNstatus.get() == 0):
3490  RUNstatus.set(1)
3491  if AWGSync.get() == 0:
3492  session.flush()
3493  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
3494  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
3495  BAWGEnab()
3496  if not session.continuous:
3497  session.start(0)
3498  time.sleep(0.02) # wait awhile here for some reason
3499  elif session.continuous:
3500  session.end()
3501  session.flush()
3502  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
3503  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
3504 
3516  BAWGEnab()
3517  else:
3518  contloop = 0
3519  discontloop = 1
3520  if session.continuous:
3521  session.end() # end continuous session mode
3522 
3523  # UpdateTimeScreen() # Always Update
3524  if TIMEdiv >= 100:
3525  First_Slow_sweep = 0
3526  else:
3527  First_Slow_sweep = 1
3528 #$ Start running Ohmmeter tool
3529 def BStartOhm():
3530  global session, AWGSync
3531 
3532  AWGSync.set(1)
3533  if AWGSync.get() == 0:
3534  session.flush()
3535  if not session.continuous:
3536  session.start(0)
3537  time.sleep(0.02) # wait awhile here for some reason
3538  elif session.continuous:
3539  session.end()
3540  session.flush()
3541  else:
3542  contloop = 0
3543  discontloop = 1
3544  if session.continuous:
3545  session.end() # end continuous session mode
3546 
3547 def BStartIA():
3548  global AWGAFreqEntry, AWGAFreqvalue, Two_X_Sample, FWRevOne, NetworkScreenStatus, BodeDisp
3549 
3550  try:
3551  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
3552  except:
3553  AWGAFreqEntry.delete(0,"end")
3554  AWGAFreqEntry.insert(0, AWGAFreqvalue)
3555  if FWRevOne > 2.16:
3556  if AWGAFreqvalue > 10000.0:
3557  Two_X_Sample.set(1)
3558  else:
3559  Two_X_Sample.set(0)
3560  SetADC_Mux()
3561  IASourceSet()
3562  if NetworkScreenStatus.get() > 0 and BodeDisp.get() > 0:
3563  BStartBP()
3564  else:
3565  BStart()
3566 
3567 def IASourceSet():
3568  global IASource, CHA, CHB, AWGAMode, AWGBMode, AWGBIOMode, AWGSync
3569 
3570  if AWGSync.get() == 0: # running in continuous mode
3571  AWGSync.set(1)
3572  if IASource.get() == 1:
3573  CHA.mode = Mode.HI_Z # Put CHA in Hi Z split mode
3574  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3575  AWGAMode.set(2) # Set AWG A to Hi-Z
3576  else:
3577  CHA.mode = Mode.SVMI # Put CHA in Hi Z split mode
3578  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3579  AWGAMode.set(0) # Set AWG A to SVMI
3580  if AWGBIOMode.get() == 0: # if not in split I/O mode
3581  AWGBMode.set(2) # Set AWG B to Hi-Z
3582 
3583 def BStop():
3584  global RUNstatus, TimeDisp, XYDisp, FreqDisp, IADisp, session, AWGSync
3585  global CHA, CHB, contloop, discontloop
3586 
3587  if (RUNstatus.get() == 1):
3588  # print("Stoping")
3589  RUNstatus.set(0)
3590  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
3591  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
3592  if AWGSync.get() == 0: # running in continuous mode
3593  CHA.constant(0.0)
3594  CHB.constant(0.0)
3595  # print("Stoping continuous mode")
3596  # session.cancel() # cancel continuous session mode while paused
3597  if session.continuous:
3598  #print( "Is Continuous? ", session.continuous)
3599  session.end()
3600  #time.sleep(0.02)
3601  #print( "Is Continuous? ", session.continuous)
3602  else:
3603  contloop = 0
3604  discontloop = 1
3605  session.cancel()
3606 #
3607  if TimeDisp.get() > 0:
3608  UpdateTimeScreen() # Always Update screens as necessary
3609  if XYDisp.get() > 0:
3610  UpdateXYScreen()
3611  if FreqDisp.get() > 0:
3613  if IADisp.get() > 0:
3614  UpdateIAScreen()
3615 
3616 def BPower():
3617  global RUNstatus, PowerStatus, devx, PwrBt
3618 
3619  if (RUNstatus.get() == 1):
3620  BStop()
3621  if PowerStatus == 1:
3622  PowerStatus = 0
3623  PwrBt.config(style="PwrOff.TButton",text="PWR-Off")
3624  devx.ctrl_transfer( 0x40, 0x50, 49, 0, 0, 0, 100) # turn off analog power
3625  else:
3626  PowerStatus = 1
3627  PwrBt.config(style="Pwr.TButton",text="PWR-On")
3628  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
3629 
3630 def BRoll():
3631  global Roll_Mode, RollBt
3632 
3633  if Roll_Mode.get() == 1:
3634  Roll_Mode.set(0)
3635  RollBt.config(style="RollOff.TButton",text="Roll-Off")
3636  else:
3637  Roll_Mode.set(1)
3638  RollBt.config(style="Roll.TButton",text="Roll-On")
3639 
3640 
3641 def BTime():
3642  global TIMEdiv, TMsb, RUNstatus, Two_X_Sample, ETSDisp, FWRevOne, ChopMuxMode
3643  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, AWGSync
3644 
3645  try: # get time scale in mSec/div
3646  TIMEdiv = float(eval(TMsb.get()))
3647  if TIMEdiv < 0.0002:
3648  TIMEdiv = 0.01
3649  TMsb.delete(0,"end")
3650  TMsb.insert(0,TIMEdiv)
3651  except:
3652  TIMEdiv = 0.5
3653  TMsb.delete(0,"end")
3654  TMsb.insert(0,TIMEdiv)
3655  # Switch to 2X sampleling if time scale small enough and not runing ETS
3656  # and not in analog input mux Chop mode.
3657  if ETSDisp.get() == 0 and ChopMuxMode.get() == 0:
3658  Samples_per_div = TIMEdiv * 100.0 # samples per mSec @ base sample rate
3659  if FWRevOne > 2.16:
3660  if Samples_per_div < 20.0:
3661  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
3662  if NumTraces > 2 and AWGSync.get() == 0:
3663  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
3664  BStop()
3665  Two_X_Sample.set(1)
3667  else:
3668  Two_X_Sample.set(0)
3669  SetADC_Mux()
3670  #
3671  if RUNstatus.get() == 0: # if not running
3672  UpdateTimeTrace() # Update
3673 
3674 def BCHAlevel():
3675  global CHAsb, RUNstatus, CH1vpdvLevel
3676 
3677  try:
3678  CH1vpdvLevel = float(eval(CHAsb.get()))
3679  except:
3680  CHAsb.delete(0,END)
3681  CHAsb.insert(0, CH1vpdvLevel)
3682  if RUNstatus.get() == 0:
3683  UpdateTimeTrace() # if not running Update
3684 
3685 def BCHAIlevel():
3686  global CHAIsb, RUNstatus, CH1ipdvLevel
3687 
3688  try:
3689  CH1ipdvLevel = float(eval(CHAIsb.get()))
3690  except:
3691  CHAIsb.delete(0,END)
3692  CHAIsb.insert(0, CH1ipdvLevel)
3693  if RUNstatus.get() == 0:
3694  UpdateTimeTrace() # if not running Update
3695 
3696 def BCHBlevel():
3697  global CHBsb, RUNstatus, CH2vpdvLevel
3698 
3699  try:
3700  CH2vpdvLevel = float(eval(CHBsb.get()))
3701  except:
3702  CHBsb.delete(0,END)
3703  CHBsb.insert(0, CH2vpdvLevel)
3704  if RUNstatus.get() == 0:
3705  UpdateTimeTrace() # if not running Update
3706 
3707 def BCHBIlevel():
3708  global CHBIsb, RUNstatus, CH2ipdvLevel
3709 
3710  try:
3711  CH2ipdvLevel = float(eval(CHBIsb.get()))
3712  except:
3713  CHBIsb.delete(0,END)
3714  CHBIsb.insert(0, CH2ipdvLevel)
3715  if RUNstatus.get() == 0:
3716  UpdateTimeTrace() # if not running Update
3717 
3718 def BOffsetA(event):
3719  global CHAOffset, CHAVPosEntry, RUNstatus
3720 
3721  try:
3722  CHAOffset = float(eval(CHAVPosEntry.get())) # evalute entry string to a numerical value
3723  except:
3724  CHAVPosEntry.delete(0,END)
3725  CHAVPosEntry.insert(0, CHAOffset)
3726  # set new offset level
3727  if RUNstatus.get() == 0:
3728  UpdateTimeTrace() # if not running Update
3729 
3730 def BIOffsetA(event):
3731  global CHAIOffset, CHAIPosEntry, RUNstatus
3732 
3733  try:
3734  CHAIOffset = float(eval(CHAIPosEntry.get())) # evalute entry string to a numerical value
3735  except:
3736  CHAIPosEntry.delete(0,END)
3737  CHAIPosEntry.insert(0, CHAIOffset)
3738  # set new offset level
3739  if RUNstatus.get() == 0:
3740  UpdateTimeTrace() # if not running Update
3741 
3742 def BOffsetB(event):
3743  global CHBOffset, CHBVPosEntry, RUNstatus
3744 
3745  try:
3746  CHBOffset = float(eval(CHBVPosEntry.get())) # evalute entry string to a numerical value
3747  except:
3748  CHBVPosEntry.delete(0,END)
3749  CHBVPosEntry.insert(0, CHBOffset)
3750  # set new offset level
3751  if RUNstatus.get() == 0:
3752  UpdateTimeTrace() # if not running Update
3753 
3754 def BIOffsetB(event):
3755  global CHBIOffset, CHBIPosEntry, RUNstatus
3756 
3757  try:
3758  CHBIOffset = float(eval(CHBIPosEntry.get())) # evalute entry string to a numerical value
3759  except:
3760  CHBIPosEntry.delete(0,END)
3761  CHBIPosEntry.insert(0, CHBIOffset)
3762  # set new offset level
3763  if RUNstatus.get() == 0:
3764  UpdateTimeTrace() # if not running Update
3765 
3766 def TimeCheckBox():
3767  global TimeDisp, ckb1
3768  if TimeDisp.get() == 1:
3769  ckb1.config(style="Enab.TCheckbutton")
3770  else:
3771  ckb1.config(style="Disab.TCheckbutton")
3772 #
3773 def XYCheckBox():
3774  global XYDisp, ckb2
3775  if XYDisp.get() == 1:
3776  ckb2.config(style="Enab.TCheckbutton")
3777  else:
3778  ckb2.config(style="Disab.TCheckbutton")
3779 #
3780 def FreqCheckBox():
3781  global FreqDisp, ckb3, OOTckb3, OOTScreenStatus
3782  if FreqDisp.get() == 1:
3783  if OOTScreenStatus.get() == 0:
3784  ckb3.config(style="Enab.TCheckbutton")
3785  else:
3786  OOTckb3.config(style="Enab.TCheckbutton")
3787  else:
3788  if OOTScreenStatus.get() == 0:
3789  ckb3.config(style="Disab.TCheckbutton")
3790  else:
3791  OOTckb3.config(style="Disab.TCheckbutton")
3792 #
3793 def BodeCheckBox():
3794  global BodeDisp, ckb5, AWGSync, OOTckb5, OOTScreenStatus
3795  if BodeDisp.get() == 1:
3796  AWGSync.set(1)
3797  if OOTScreenStatus.get() == 0:
3798  ckb5.config(style="Enab.TCheckbutton")
3799  else:
3800  OOTckb5.config(style="Enab.TCheckbutton")
3801  else:
3802  if OOTScreenStatus.get() == 0:
3803  ckb5.config(style="Disab.TCheckbutton")
3804  else:
3805  OOTckb5.config(style="Disab.TCheckbutton")
3806 #
3807 def IACheckBox():
3808  global IADisp, ckb4, OOTckb4, OOTScreenStatus
3809  if IADisp.get() == 1:
3810  if OOTScreenStatus.get() == 0:
3811  ckb4.config(style="Enab.TCheckbutton")
3812  else:
3813  OOTckb4.config(style="Enab.TCheckbutton")
3814  else:
3815  if OOTScreenStatus.get() == 0:
3816  ckb4.config(style="Disab.TCheckbutton")
3817  else:
3818  OOTckb4.config(style="Disab.TCheckbutton")
3819 #
3820 def PhACheckBox():
3821  global PhADisp, Phckb, OOTphckb, OOTScreenStatus
3822  if PhADisp.get() == 1:
3823  if OOTScreenStatus.get() == 0:
3824  phckb.config(style="Enab.TCheckbutton")
3825  else:
3826  OOTphckb.config(style="Enab.TCheckbutton")
3827  else:
3828  if OOTScreenStatus.get() == 0:
3829  phckb.config(style="Disab.TCheckbutton")
3830  else:
3831  OOTphckb.config(style="Disab.TCheckbutton")
3832 #
3833 def OhmCheckBox():
3834  global OhmDisp, ckb6, OOTckb6, OOTScreenStatus
3835  if OhmDisp.get() == 1:
3836  if OOTScreenStatus.get() == 0:
3837  ckb6.config(style="Enab.TCheckbutton")
3838  else:
3839  OOTckb6.config(style="Enab.TCheckbutton")
3840  else:
3841  if OOTScreenStatus.get() == 0:
3842  ckb6.config(style="Disab.TCheckbutton")
3843  else:
3844  OOTckb6.config(style="Disab.TCheckbutton")
3845 #
3846 def ETSCheckBox():
3847  global ETSDisp, enb1
3848  if ETSDisp.get() == 1:
3849  enb1.config(style="Enab.TCheckbutton")
3850  else:
3851  try:
3852  enb1.config(style="Disab.TCheckbutton")
3853  except:
3854  donothing()
3855 # ========================= Main routine ====================================
3856 
3857 def Analog_In():
3858  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp, SpectrumScreenStatus, HWRevOne
3859  global PhADisp, IADisp, IAScreenStatus, CutDC, DevOne, AWGBMode, MuxEnb, BodeScreenStatus, BodeDisp
3860  global MuxScreenStatus, VBuffA, VBuffB, MuxSync, AWGBIOMode
3861  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD, MuxChan
3862  global ShowC1_V, ShowC2_V, ShowC2_I, SMPfft
3863  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3864  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3865  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3866  global SV1, SI1, SV2, SI2, SVA_B, Closed
3867  global FregPoint, FBins, FStep, TRACEaverage
3868  # Analog Mux channel measurement variables
3869  global TRACEresetTime, TRACEmodeTime, TgInput, SettingsStatus, TRIGGERsample
3870  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode
3871  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3872  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3873  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3874  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3875  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3876  global DlogFile, Dlog_open, dlog, UserAString, UserBString, MeasUserA, MeasUserB
3877 
3878  while (Closed == 0): # Main loop
3879  # RUNstatus = 1 : Open Acquisition
3880  if (RUNstatus.get() == 1) or (RUNstatus.get() == 2):
3881  if SettingsStatus.get() == 1:
3882  SettingsUpdate() # Make sure current entries in Settings controls are up to date
3883  if TimeDisp.get() > 0 or XYDisp.get() > 0 or PhADisp.get() > 0:
3884  if MuxScreenStatus.get() == 0:
3885  MuxChan = -1
3886  Analog_Time_In()
3887  if dlog.get() > 0: # Check to see if Data Logging is On
3888  tstr1 = time.time()-Ztime
3889  DlogString = '{0:.3f}, '.format(tstr1)
3890  if MeasUserA.get() == 1:
3891  try:
3892  TempValue = eval(UserAString)
3893  V1String = '{0:.4f}'.format(TempValue) + ", "
3894  except:
3895  V1String = "####, "
3896  DlogString = DlogString + V1String
3897  if MeasUserB.get() == 1:
3898  try:
3899  TempValue = eval(UserBString)
3900  V1String = '{0:.4f} '.format(TempValue) + ", "
3901  except:
3902  V1String = "####, "
3903  DlogString = DlogString + V1String
3904  DlogString = DlogString + " \n"
3905  DlogFile.write( DlogString )
3906  else:
3907  MuxChan = 0
3908  if DualMuxMode.get() == 1: # force split I/O mode if dual mux mode set
3909  AWGAIOMode.set(1)
3910  AWGBIOMode.set(1)
3911  ShowC1_V.set(0) # force A voltage trace off
3912  ShowC2_V.set(0) # force B voltage trace off
3913  if HWRevOne == "D" :
3914  # force channel B to always be in High-Z mode for Rev D hardware or if not in split I/O mode
3915  AWGBMode.set(2)
3916  if AWGBIOMode.get() == 0: # if not in split I/O mode
3917  ShowC2_I.set(0) # no need to show CH-B current
3918  if MuxEnb.get() == 1:
3919  PIO2 = 0x51
3920  else:
3921  PIO2 = 0x50
3922  if MuxSync.get() == 0:
3923  PIO3 = 0x51
3924  PIO3x = 0x50
3925  else:
3926  PIO3 = 0x50
3927  PIO3x = 0x51
3928  #
3929  if ChopMuxMode.get() == 0: # do this if in alternate sweep mode
3930  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3931  TRACEresetTime = True # Clear the memory for averaging
3932  if Show_CBA.get() == 1:
3933  MuxChan = 0
3934  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3935  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3936  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO enable
3937  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 1 sync pulse for sweep start
3938  time.sleep(0.002)
3939  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3940  if TRACEmodeTime.get() == 1:
3941  if TRACEresetTime == True:
3942  TRACEresetTime = False
3943  # Save previous trace in memory for average trace
3944  VmemoryMuxA = VBuffMA
3945  Analog_Time_In()
3946  if Show_CBB.get() == 1:
3947  MuxChan = 1
3948  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3949  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3950  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3951  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3952  time.sleep(0.002)
3953  devx.ctrl_transfer(0x40, PIO3x, 3, 0, 0, 0, 100) # set PIO 3 to return value
3954  if TRACEmodeTime.get() == 1:
3955  if TRACEresetTime == True:
3956  TRACEresetTime = False
3957  # Save previous trace in memory for average trace
3958  VmemoryMuxB = VBuffMB
3959  Analog_Time_In()
3960  if Show_CBC.get() == 1:
3961  MuxChan = 2
3962  if DualMuxMode.get() == 1:
3963  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3964  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3965  else:
3966  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3967  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3968  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3969  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3970  time.sleep(0.002)
3971  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3972  if TRACEmodeTime.get() == 1:
3973  if TRACEresetTime == True:
3974  TRACEresetTime = False
3975  # Save previous trace in memory for average trace
3976  VmemoryMuxC = VBuffMC
3977  Analog_Time_In()
3978  if Show_CBD.get() == 1:
3979  MuxChan = 3
3980  if DualMuxMode.get() == 1:
3981  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3982  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3983  else:
3984  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3985  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3986  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3987  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3988  time.sleep(0.002)
3989  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3990  if TRACEmodeTime.get() == 1:
3991  if TRACEresetTime == True:
3992  TRACEresetTime = False
3993  # Save previous trace in memory for average trace
3994  VmemoryMuxD = VBuffMD
3995  Analog_Time_In()
3996  if Show_CBA.get() == 0 and Show_CBB.get() == 0 and Show_CBC.get() == 0 and Show_CBD.get() == 0 and ShowC1_V.get() == 1:
3997  Analog_Time_In()
3998  else: # do this if in Chop mode
3999  MuxChan = 0
4000  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO_2 enable control
4001  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
4002  TRACEresetTime = True # Clear the memory for averaging
4003  elif TRACEmodeTime.get() == 1:
4004  if TRACEresetTime == True:
4005  TRACEresetTime = False
4006  # Save previous traces in memory for average trace
4007  VmemoryMuxA = VBuffMA
4008  VmemoryMuxB = VBuffMB
4009  VmemoryMuxC = VBuffMC
4010  VmemoryMuxD = VBuffMD
4011  Analog_Time_In()
4012  if (FreqDisp.get() > 0 and SpectrumScreenStatus.get() == 1) or (IADisp.get() > 0 and IAScreenStatus.get() == 1) or (BodeDisp.get() > 0 and BodeScreenStatus.get() == 1):
4013  if IADisp.get() > 0 or BodeDisp.get() > 0:
4014  CutDC.set(1) # remove DC portion of waveform
4015  AWGSync.set(1) # Impedance analyzer and Bode plotter must be run in discontinuous mode
4016  if BodeDisp.get() > 0:
4017  if LoopNum.get() <= len(FStep):
4018  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
4019  if FregPoint <= 5.0:
4020  SMPfft = 32768*2
4021  elif FregPoint <= 10.0:
4022  SMPfft = 32768
4023  elif FregPoint < 100.0:
4024  SMPfft = 16384
4025  elif FregPoint < 500.0:
4026  SMPfft = 8192
4027  elif FregPoint < 2000.0:
4028  SMPfft = 4096
4029  else:
4030  SMPfft = 2048
4031  if Two_X_Sample.get() > 0 and FregPoint < 2000.0:
4032  SMPfft = SMPfft * 2
4033 
4034  Analog_Freq_In()
4035  elif OhmRunStatus.get() == 1 and OhmDisp.get() == 1:
4036  Ohm_Analog_In()
4037  else:
4038  time.sleep(0.01) # slow down loop while not running to reduce CPU usage
4039  root.update_idletasks()
4040  root.update()
4041 
4042 def Ohm_Analog_In():
4043  global RMode, CHATestVEntry, CHATestREntry, CHA, CHB, devx, OhmA0, OhmA1, discontloop
4044  global AWGAMode, AWGBMode, AWGAShape, AWGSync, AWGBTerm, AWGAOffsetEntry
4045  global AWGAIOMode, AWGBIOMode, Two_X_Sample, Rint
4046 
4047 # Do input probe Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
4048  try:
4049  InOffA = float(eval(CHAVOffsetEntry.get()))
4050  except:
4051  CHAVOffsetEntry.delete(0,END)
4052  CHAVOffsetEntry.insert(0, InOffA)
4053  try:
4054  InGainA = float(eval(CHAVGainEntry.get()))
4055  except:
4056  CHAVGainEntry.delete(0,END)
4057  CHAVGainEntry.insert(0, InGainA)
4058  try:
4059  InOffB = float(eval(CHBVOffsetEntry.get()))
4060  except:
4061  CHBVOffsetEntry.delete(0,END)
4062  CHBVOffsetEntry.insert(0, InOffB)
4063  try:
4064  InGainB = float(eval(CHBVGainEntry.get()))
4065  except:
4066  CHBVGainEntry.delete(0,END)
4067  CHBVGainEntry.insert(0, InGainB)
4068  try:
4069  CurOffA = float(CHAIOffsetEntry.get())
4070  except:
4071  CurOffA = 0.0
4072  try:
4073  CurOffB = float(CHBIOffsetEntry.get())
4074  except:
4075  CurOffB = 0.0
4076  try:
4077  CurGainA = float(CHAIGainEntry.get())
4078  except:
4079  CurGainA = 1.0
4080  try:
4081  CurGainB = float(CHBIGainEntry.get())
4082  except:
4083  CurGainB = 1.0
4084  try:
4085  chatestv = float(eval(CHATestVEntry.get()))
4086  if chatestv > 5.0:
4087  chatestv = 5.0
4088  CHATestVEntry.delete(0,END)
4089  CHATestVEntry.insert(0, chatestv)
4090  except:
4091  CHATestVEntry.delete(0,END)
4092  CHATestVEntry.insert(0, chatestv)
4093  try:
4094  chatestr = float(eval(CHATestREntry.get()))
4095  except:
4096  CHATestREntry.delete(0,END)
4097  CHATestREntry.insert(0, chatestr)
4098  #
4099  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
4100  Two_X_Sample.set(0) # make sure we are in 1V sample rate mode
4101  SetADC_Mux()
4102  # set A and B channels
4103  AWGAMode.set(0) # Set AWG A to SVMI
4104  AWGAShape.set(0) # DC
4105  AWGBMode.set(2) # Set AWG B to Hi-Z
4106  AWGAIOMode.set(0) # turn off Split I/O mode
4107  AWGBIOMode.set(0) # turn off Split I/O mode
4108  AWGAOffsetEntry.delete(0,"end")
4109  AWGAOffsetEntry.insert(0, chatestv)
4110  BAWGAModeLabel()
4111  BAWGBModeLabel() # update AWG labels
4112 
4113  if RMode.get() == 0:
4114  AWGBTerm.set(0)
4115  else:
4116  AWGBTerm.set(1)
4117  #
4118  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4119  if discontloop > 0:
4120  session.flush()
4121  else:
4122  discontloop = 1
4123  time.sleep(0.01)
4124  BAWGEnab()
4125  ADsignal1 = devx.get_samples(210) # get samples for both channel A and B
4126  # time.sleep(1000.0/SHOWsamples)
4127  else: # running in continuous mode
4128  if session.continuous:
4129  ADsignal1 = devx.read(210, -1, True) # get samples for both channel A and B
4130  #
4131  # get_samples returns a list of values for voltage [0] and current [1]
4132  for index in range(200): # calculate average
4133  DCVA0 += ADsignal1[index+10][0][0] # VAdata # Sum for average CA voltage
4134  DCVB0 += ADsignal1[index+10][1][0] # VBdata # Sum for average CB voltage
4135  DCIA0 += ADsignal1[index+10][0][1] # Sum for average CA current
4136  DCIB0 += ADsignal1[index+10][1][1] # Sum for average CB current
4137 
4138  DCVA0 = DCVA0 / 200.0 # calculate average
4139  DCVB0 = DCVB0 / 200.0 # calculate average
4140  DCIA0 = DCIA0 / 200.0 # calculate average
4141  DCIB0 = DCIB0 / 200.0 # calculate average
4142  DCVA0 = (DCVA0 - InOffA) * InGainA
4143  DCVB0 = (DCVB0 - InOffB) * InGainB
4144  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA
4145  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB
4146  # Rint = 1000000 # nominal ALM1000 input resistance is 1 Mohm
4147  if RMode.get() == 0: # external resistor
4148  DCM = chatestr * (DCVB0/(DCVA0-DCVB0))
4149  DCR = (DCM * Rint) / (Rint - DCM) # correct for channel B input resistance
4150  else: # use internal 50 ohm resistor
4151  DCR = chatestr * ((DCVA0-DCVB0)/DCVB0)
4152  if DCR < 1000:
4153  OhmString = '{0:.2f} '.format(DCR) + "Ohms "# format with 2 decimal places
4154  else:
4155  OhmString = '{0:.3f} '.format(DCR/1000) + "KOhms " # divide by 1000 and format with 3 decimal places
4156  IAString = "Meas " + ' {0:.2f} '.format(DCIA0) + " mA " + ' {0:.2f} '.format(DCVB0) + " V"
4157  OhmA0.config(text = OhmString) # change displayed value
4158  OhmA1.config(text = IAString) # change displayed value
4159 #
4160  time.sleep(0.1)
4161  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4162 
4164 def Analog_Time_In():
4165  global TIMEdiv, TMsb, TRACEmodeTime, TRACEresetTime, TRACEaverage
4166  global VBuffMA, VmemoryMuxA, VBuffMB, VmemoryMuxB, VBuffMC, VmemoryMuxC, VBuffMD, VmemoryMuxD
4167  global CHAVOffsetEntry, CHAVGainEntry, CHBVOffsetEntry, CHBVGainEntry
4168  global CHAIOffsetEntry, CHBIOffsetEntry, CHAIGainEntry, CHBIGainEntry
4169  global InOffA, InGainA, InOffB, InGainB
4170  global CurOffA, CurOffB, CurGainA, CurGainB
4171  global PhADisp, PhAScreenStatus, MuxScreenStatus, ChopMuxMode
4172  global First_Slow_sweep, Roll_Mode
4173  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4174 
4175  # get time scale
4176  try:
4177  TIMEdiv = eval(TMsb.get())
4178  except:
4179  TIMEdiv = 0.5
4180  TMsb.delete(0,"end")
4181  TMsb.insert(0,TIMEdiv)
4182  if TIMEdiv < 0.0002:
4183  TIMEdiv = 0.01
4184  #
4185 # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
4186  try:
4187  InOffA = float(eval(CHAVOffsetEntry.get()))
4188  except:
4189  CHAVOffsetEntry.delete(0,END)
4190  CHAVOffsetEntry.insert(0, InOffA)
4191  try:
4192  InGainA = float(eval(CHAVGainEntry.get()))
4193  except:
4194  CHAVGainEntry.delete(0,END)
4195  CHAVGainEntry.insert(0, InGainA)
4196  try:
4197  InOffB = float(eval(CHBVOffsetEntry.get()))
4198  except:
4199  CHBVOffsetEntry.delete(0,END)
4200  CHBVOffsetEntry.insert(0, InOffB)
4201  try:
4202  InGainB = float(eval(CHBVGainEntry.get()))
4203  except:
4204  CHBVGainEntry.delete(0,END)
4205  CHBVGainEntry.insert(0, InGainB)
4206  try:
4207  CurOffA = float(CHAIOffsetEntry.get()) #/1000.0 # convert to Amps # leave in mA
4208  except:
4209  CurOffA = 0.0
4210  try:
4211  CurOffB = float(CHBIOffsetEntry.get())#/1000.0 # convert to Amps
4212  except:
4213  CurOffB = 0.0
4214  try:
4215  CurGainA = float(CHAIGainEntry.get())
4216  except:
4217  CurGainA = 1.0
4218  try:
4219  CurGainB = float(CHBIGainEntry.get())
4220  except:
4221  CurGainB = 1.0
4222 # Dedecide which Fast or Slow sweep routine to call
4223  if Roll_Mode.get() > 0: # 200:
4224  Analog_Roll_time() # rolling trace
4225  else:
4226  First_Slow_sweep = 0
4228 #
4229  if PhADisp.get() > 0 and PhAScreenStatus.get() == 1:
4230  Analog_Phase_In()
4231 #
4232 # Process captured time dmain signals to extract magnitude and phase data
4233 def Analog_Phase_In():
4234  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB
4235  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
4236  global VAresult, VBresult, IAresult, IBresult, VABresult, IABresult
4237  global PhaseVA, PhaseVB, PhaseIA, PhaseIB, PhaseVAB, PhaseIAB
4238  global VMAresult, VMBresult,VMCresult, VMDresult
4239  global PhaseVMA, PhaseVMB, PhaseVMC, PhaseVMD
4240  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4241  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4242  global DCVMuxA, DCVMuxB, DCVMuxC, DCVMuxD
4243  global SHOWsamples, SMPfft, hldn, MuxScreenStatus, MuxChan, ChopMuxMode
4244  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
4245  global FFTwindowshape, ZEROstuffing
4246 
4247  if len(VBuffA) < SMPfft: # put up warning to reduce number of FFT Samples or increase Time/Div time base
4249  #showwarning("WARNING","Redude Number of Samples \n Or Increas Time/Div time base.")
4250  #BStop() # Force Stop loop if running
4251  #return
4252  # Do an FFT on captured voltage and current buffer
4253  StartSmp = hldn
4254  StopSmp = hldn + SMPfft
4256  REX = []
4257  PhaseVA = []
4258  PhaseIA = []
4259  PhaseIB = []
4260  PhaseIAB = []
4261  # Convert list to numpy array REX for faster Numpy calculations
4262  # Take the first SMPfft samples of VBuffA
4263  REX = numpy.array(VBuffA[StartSmp:StopSmp]-DCV1) # Make a numpy arry of the list
4264 
4265  # Set Analog level display value MAX value is 5 volts for ALM1000
4266  REX = REX / 5.0
4267 
4268  # Do the FFT window function
4269  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4270  # FFT with numpy
4271  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4272  PhaseVA = numpy.angle(ALL, deg=True) # calculate angle
4273  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4274 
4275  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4276  ALL = ALL[0:le] # So take only first half of the array
4277  PhaseVA = PhaseVA[0:le]
4278  Totalcorr = 7.07106 / SMPfft # RMS For VOLTAGE!
4279  VAresult = Totalcorr * ALL
4280  # check to see if analog Mux is being used?
4281  if MuxScreenStatus.get() == 0:
4282  PhaseVB = []
4283  PhaseVAB = []
4284  # Now VB array
4285  REX = numpy.array(VBuffB[StartSmp:StopSmp]-DCV2) # Make a numpy arry of the list
4286 
4287  # Set Analog level display value MAX value is 5 volts for ALM1000
4288  REX = REX / 5.0
4289 
4290  # Do the FFT window function
4291  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4292 
4293  # FFT with numpy
4294  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4295  PhaseVB = numpy.angle(ALL, deg=True) # calculate angle
4296  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4297 
4298  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4299  ALL = ALL[0:le] # So take only first half of the array
4300  PhaseVB = PhaseVB[0:le]
4301  RMScorr = 7.07106 / SMPfft # For rMS VOLTAGE!
4302  VBresult = RMScorr * ALL
4303 
4304  # Now VAB array
4305  REX = numpy.array(VBuffA[StartSmp:StopSmp]-VBuffB[StartSmp:StopSmp]) # Make a numpy arry of the list
4306  REX = REX - (DCV1-DCV2) # cut any remaining DC
4307  # Set Analog level display value MAX value is 5 volts for ALM1000
4308  REX = REX / 5.0
4309 
4310  # Do the FFT window function
4311  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4312 
4313  # FFT with numpy
4314  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4315  PhaseVAB = numpy.angle(ALL, deg=True) # calculate angle
4316  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4317 
4318  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4319  ALL = ALL[0:le] # So take only first half of the array
4320  PhaseVAB = PhaseVAB[0:le]
4321  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4322  VABresult = RMScorr * ALL
4323  else: # Do FFTs on Mux buffers as needed if MuxScreenStatus.get() > 0:
4324  if MuxChan == 0 or ChopMuxMode.get() > 0: #
4325  PhaseVMA = []
4326  # Now VMuxA array
4327  REX = numpy.array(VBuffMA[StartSmp:StopSmp]-DCVMuxA) # Make a numpy arry of the list
4328 
4329  # Set Analog level display value MAX value is 5 volts for ALM1000
4330  REX = REX / 5.0
4331 
4332  # Do the FFT window function
4333  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4334 
4335  # FFT with numpy
4336  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4337  PhaseVMA = numpy.angle(ALL, deg=True) # calculate angle
4338  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4339 
4340  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4341  ALL = ALL[0:le] # So take only first half of the array
4342  PhaseVMA = PhaseVMA[0:le]
4343  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4344  VMAresult = RMScorr * ALL
4345  if MuxChan == 1 or ChopMuxMode.get() > 0: # MuxChan = 1
4346  PhaseVMB = []
4347  # Now VMuxA array
4348  REX = numpy.array(VBuffMB[StartSmp:StopSmp]-DCVMuxB) # Make a numpy arry of the list
4349 
4350  # Set Analog level display value MAX value is 5 volts for ALM1000
4351  REX = REX / 5.0
4352 
4353  # Do the FFT window function
4354  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4355 
4356  # FFT with numpy
4357  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4358  PhaseVMB = numpy.angle(ALL, deg=True) # calculate angle
4359  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4360 
4361  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4362  ALL = ALL[0:le] # So take only first half of the array
4363  PhaseVMB = PhaseVMB[0:le]
4364  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4365  VMBresult = RMScorr * ALL
4366  if MuxChan == 2 or ChopMuxMode.get() > 0: # MuxChan = 2
4367  PhaseVMC = []
4368  # Now VMuxA array
4369  REX = numpy.array(VBuffMC[StartSmp:StopSmp]-DCVMuxC) # Make a numpy arry of the list
4370 
4371  # Set Analog level display value MAX value is 5 volts for ALM1000
4372  REX = REX / 5.0
4373 
4374  # Do the FFT window function
4375  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4376 
4377  # FFT with numpy
4378  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4379  PhaseVMC = numpy.angle(ALL, deg=True) # calculate angle
4380  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4381 
4382  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4383  ALL = ALL[0:le] # So take only first half of the array
4384  PhaseVMC = PhaseVMC[0:le]
4385  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4386  VMCresult = RMScorr * ALL
4387  if MuxChan == 3 or ChopMuxMode.get() > 0: # MuxChan = 3
4388  PhaseVMD = []
4389  # Now VMuxA array
4390  REX = numpy.array(VBuffMD[StartSmp:StopSmp]-DCVMuxD) # Make a numpy arry of the list
4391 
4392  # Set Analog level display value MAX value is 5 volts for ALM1000
4393  REX = REX / 5.0
4394 
4395  # Do the FFT window function
4396  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4397 
4398  # FFT with numpy
4399  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4400  PhaseVMD = numpy.angle(ALL, deg=True) # calculate angle
4401  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4402 
4403  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4404  ALL = ALL[0:le] # So take only first half of the array
4405  PhaseVMD = PhaseVMD[0:le]
4406  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4407  VMDresult = RMScorr * ALL
4408  # Now IA array
4409  REX = numpy.array(IBuffA[StartSmp:StopSmp]-DCI1) # Make a numpy arry of the list
4410 
4411  # Set Analog level display value MAX value is 0.2 amps for ALM1000
4412  REX = REX / 0.5
4413 
4414  # Do the FFT window function
4415  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4416 
4417  # FFT with numpy
4418  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4419  PhaseIA = numpy.angle(ALL, deg=True) # calculate angle
4420  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4421 
4422  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4423  ALL = ALL[0:le] # So take only first half of the array
4424  PhaseIA = PhaseIA[0:le]
4425  RMScorr = 0.707106 / SMPfft # RMS For current!
4426  IAresult = RMScorr * ALL
4427 
4428  # Now IB array
4429  REX = numpy.array(IBuffB[StartSmp:StopSmp]-DCI2) # Make a numpy arry of the list
4430 
4431  # Set Analog level display value MAX value is 0.2 amps for ALM1000
4432  REX = REX / 0.5
4433 
4434  # Do the FFT window function
4435  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4436 
4437  # FFT with numpy
4438  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4439  PhaseIB = numpy.angle(ALL, deg=True) # calculate angle
4440  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4441 
4442  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4443  ALL = ALL[0:le] # So take only first half of the array
4444  PhaseIB = PhaseIB[0:le]
4445  RMScorr = 0.707106 / SMPfft # RMS For current!
4446  IBresult = RMScorr * ALL
4447  # Now IA+B array
4448  IDC = DCI1 + DCI2
4449  REX = numpy.array(IBuffA[StartSmp:StopSmp]+IBuffB[StartSmp:StopSmp]) # -DCI1 Make a numpy arry of the list
4450  REX = REX - IDC
4451  # Set Analog level display value MAX value is 0.2 amps for ALM1000
4452  REX = REX / 0.5
4453 
4454  # Do the FFT window function
4455  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4456 
4457  # FFT with numpy
4458  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4459  PhaseIAB = numpy.angle(ALL, deg=True) # calculate angle
4460  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4461 
4462  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4463  ALL = ALL[0:le] # So take only first half of the array
4464  PhaseIAB = PhaseIAB[0:le]
4465  RMScorr = 0.707106 / SMPfft # RMS For current!
4466  IABresult = RMScorr * ALL
4467 
4468 #
4469  UpdatePhAAll()
4470 #
4471 # Right now this is a limited attempt to plot rolling sweep.
4472 def Analog_Roll_time():
4473  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
4474  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4475  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
4476  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
4477  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
4478  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
4479  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
4480  global CHA, CHB, session, devx, discontloop, contloop
4481  global TRACES, TRACESread, TRACEsize, First_Slow_sweep, Roll_Mode # , ShiftPointer
4482  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
4483  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, GRW
4484  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
4485  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
4486  global SCREENrefresh, DCrefresh
4487  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4488  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4489  global SV1, SI1, SV2, SI2, SVA_B
4490  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4491  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
4492  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4493  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
4494  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
4495  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
4496  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4497  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4498  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4499  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
4500  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
4501  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
4502  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
4503  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
4504  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4505  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4506  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4507  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4508  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4509  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4510  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4511 
4512  # Starting acquisition
4513  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
4514  #
4515  NumSamples = 10 # int(SAMPLErate/TIMEdiv)
4516  if First_Slow_sweep == 0:
4517  VBuffA = numpy.ones(GRW)
4518  VBuffB = numpy.ones(GRW)
4519  IBuffA = numpy.ones(GRW)
4520  IBuffB = numpy.ones(GRW)
4521  DBuff0 = numpy.ones(GRW)
4522  DBuff1 = numpy.ones(GRW)
4523  DBuff2 = numpy.ones(GRW)
4524  DBuff3 = numpy.ones(GRW)
4525  First_Slow_sweep = 1
4526  if len(VBuffA) != GRW:
4527  VBuffA = numpy.ones(GRW)
4528  VBuffB = numpy.ones(GRW)
4529  IBuffA = numpy.ones(GRW)
4530  IBuffB = numpy.ones(GRW)
4531  DBuff0 = numpy.ones(GRW)
4532  DBuff1 = numpy.ones(GRW)
4533  DBuff2 = numpy.ones(GRW)
4534  DBuff3 = numpy.ones(GRW)
4535  #
4536  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
4537  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4538  if discontloop > 0:
4539  session.flush()
4540  else:
4541  discontloop = 1
4542  BAWGEnab()
4543  ADsignal1 = devx.get_samples(NumSamples) # get samples for both channel A and B
4544  # waite to finish then return to open termination
4545  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4546  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4547  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4548  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4549 
4550  else: # running in continuous mode
4551  if session.continuous:
4552  if MuxScreenStatus.get() > 0:
4553  devx.flush(-1, True)
4554  DummySamples = NumSamples*2
4555  if DummySamples < 10000:
4556  DummySamples = 10000
4557  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4558  ADsignal1 = devx.read(NumSamples, -1, True) # True) get samples for both channel A and B
4559  #
4560  else:
4561  ADsignal1 = devx.get_samples(NumSamples) # , True) # get samples for both channel A and B
4562  # get_samples returns a list of values for voltage [0] and current [1]
4563  for index in range(NumSamples): # calculate average
4564  DCVA0 += ADsignal1[index][0][0] # Sum for average CA voltage
4565  DCVB0 += ADsignal1[index][1][0] # Sum for average CB voltage
4566  DCIA0 += ADsignal1[index][0][1] # Sum for average CA current
4567  DCIB0 += ADsignal1[index][1][1] # Sum for average CB current
4568  DCVA0 = DCVA0/(NumSamples) # calculate V average
4569  DCVB0 = DCVB0/(NumSamples) # calculate V average
4570  DCIA0 = DCIA0/(NumSamples) # calculate I average
4571  DCIB0 = DCIB0/(NumSamples) # calculate I average
4572  # Adjust for gain and offset
4573  DCVA0 = (DCVA0 - InOffA) * InGainA
4574  DCVB0 = (DCVB0 - InOffB) * InGainB
4575  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA # convert to mA
4576  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB # convert to mA
4577 # next new sample
4578  VBuffA = shift_buffer(VBuffA, -1, DCVA0)
4579  VBuffB = shift_buffer(VBuffB, -1, DCVB0)
4580  IBuffA = shift_buffer(IBuffA, -1, DCIA0)
4581  IBuffB = shift_buffer(IBuffB, -1, DCIB0)
4582 # Make digital input buffer if that port is an input
4583  if D0.get() == 0:
4584  DBuff0 = shift_buffer(DBuff0, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100))
4585  if D1.get() == 0:
4586  DBuff1 = shift_buffer(DBuff1, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100))
4587  if D2.get() == 0:
4588  DBuff2 = shift_buffer(DBuff2, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100))
4589  if D3.get() == 0:
4590  DBuff3 = shift_buffer(DBuff3, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100))
4591 # Calculate measurement values
4592  SampleEnd = len(VBuffA) - 1
4593  Cal_trace_scalars(0, SampleEnd)
4594 #
4595  if TimeDisp.get() > 0:
4596  MakeTimeTrace() # Update the traces
4597  UpdateTimeScreen() # Update the screen
4598  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4599  UpdateXYAll() # Update Data, trace and XY screen
4600  if MeasureStatus.get() > 0:
4602  # update screens
4603 #
4604 def Analog_Chop_Time():
4605  global ADsignal1, VBuffMA, VBuffMB, VBuffMC, VBuffMD
4606  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4607  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4608  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4609  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4610  global SHOWsamples, ChopModeFilter
4611 
4612  VBuffMA = [] # Clear the Mux A array
4613  VBuffMB = [] # Clear the Mux B array
4614  VBuffMC = [] # Clear the Mux C array
4615  VBuffMD = [] # Clear the Mux D array
4616  index = 1
4617  while index < SHOWsamples-3: # build arrays VBuffMA, VBuffMB, VBuffMC, VBuffMD
4618  pointer = 0
4619  while pointer < 4:
4620  VBuffMA.append(ADsignal1[index+3][0][0]) # chop AIN into Mux A and B
4621  VBuffMB.append(ADsignal1[index+1][0][0])
4622  VBuffMC.append(ADsignal1[index+3][1][0]) # chop BIN into Mux C and D
4623  VBuffMD.append(ADsignal1[index+1][1][0])
4624  pointer = pointer + 1
4625  index = index + 4
4626  VBuffMA = numpy.array(VBuffMA)
4627  VBuffMB = numpy.array(VBuffMB)
4628  VBuffMC = numpy.array(VBuffMC)
4629  VBuffMD = numpy.array(VBuffMD)
4630  # apply a digital filter to interpolate back to 100 KSPS
4631  VBuffMA = numpy.pad(VBuffMA, (4, 0), "edge")
4632  VBuffMA = numpy.convolve(VBuffMA, ChopModeFilter )
4633  VBuffMA = numpy.roll(VBuffMA, -4)
4634  VBuffMB = numpy.pad(VBuffMB, (4, 0), "edge")
4635  VBuffMB = numpy.convolve(VBuffMB, ChopModeFilter)
4636  VBuffMB = numpy.roll(VBuffMB, -6)
4637  VBuffMC = numpy.pad(VBuffMC, (4, 0), "edge")
4638  VBuffMC = numpy.convolve(VBuffMC, ChopModeFilter )
4639  VBuffMC = numpy.roll(VBuffMC, -4)
4640  VBuffMD = numpy.pad(VBuffMD, (4, 0), "edge")
4641  VBuffMD = numpy.convolve(VBuffMD, ChopModeFilter )
4642  VBuffMD = numpy.roll(VBuffMD, -6)
4643  # calculate waveform scalers
4644  EndSample = SHOWsamples-4
4645  DCVMuxA = numpy.mean(VBuffMA[:EndSample])
4646  MinVMuxA = numpy.amin(VBuffMA[:EndSample])
4647  MaxVMuxA = numpy.amax(VBuffMA[:EndSample])
4648  MidVMuxA = (MaxVMuxA+MinVMuxA)/2.0
4649  PPVMuxA = MaxVMuxA-MinVMuxA
4650 #
4651  DCVMuxB = numpy.mean(VBuffMB[:EndSample])
4652  MinVMuxB = numpy.amin(VBuffMB[:EndSample])
4653  MaxVMuxB = numpy.amax(VBuffMB[:EndSample])
4654  MidVMuxB = (MaxVMuxB+MinVMuxB)/2.0
4655  PPVMuxB = MaxVMuxB-MinVMuxB
4656 #
4657  DCVMuxC = numpy.mean(VBuffMC[:EndSample])
4658  MinVMuxC = numpy.amin(VBuffMC[:EndSample])
4659  MaxVMuxC = numpy.amax(VBuffMC[:EndSample])
4660  MidVMuxC = (MaxVMuxC+MinVMuxC)/2.0
4661  PPVMuxC = MaxVMuxC-MinVMuxC
4662 #
4663  DCVMuxD = numpy.mean(VBuffMD[:EndSample])
4664  MinVMuxD = numpy.amin(VBuffMD[:EndSample])
4665  MaxVMuxD = numpy.amax(VBuffMD[:EndSample])
4666  MidVMuxD = (MaxVMuxD+MinVMuxD)/2.0
4667  PPVMuxD = MaxVMuxD-MinVMuxD
4668  # RMS value = square root of average of the data record squared
4669  SVMuxA = numpy.sqrt(numpy.mean(numpy.square(VBuffMA[:EndSample])))
4670  SVMuxB = numpy.sqrt(numpy.mean(numpy.square(VBuffMB[:EndSample])))
4671  SVMuxC = numpy.sqrt(numpy.mean(numpy.square(VBuffMC[:EndSample])))
4672  SVMuxD = numpy.sqrt(numpy.mean(numpy.square(VBuffMD[:EndSample])))
4673 #
4674 # routine for time scales faster than Slow_Sweep_Limit mSec/Div
4675 def Analog_Fast_time():
4676  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
4677  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4678  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
4679  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
4680  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
4681  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
4682  global CHA, CHB, session, devx, discontloop, contloop, DeBugMode
4683  global TRACES, TRACESread, TRACEsize, TRIGGERsampleAltA, TRIGGERsampleAltB
4684  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
4685  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, Trigger_LPF_length, LPFTrigger
4686  global SAMPLErate, SHOWsamples, SMPfft, MinSamples, MaxSamples, AWGSAMPLErate
4687  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
4688  global SCREENrefresh, DCrefresh, ETSrecord
4689  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4690  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4691  global SV1, SI1, SV2, SI2, SVA_B
4692  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4693  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
4694  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4695  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
4696  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
4697  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
4698  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4699  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4700  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4701  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
4702  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
4703  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
4704  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
4705  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode, ChopTrig
4706  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4707  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
4708  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4709  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4710  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4711  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4712  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4713  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4714  global BCVASkewEntry, BCVBSkewEntry, DigDeSkewVA, DigDeSkewVB
4715  global BCIASkewEntry, BCIBSkewEntry, DigDeSkewIA, DigDeSkewIB
4716 
4717  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
4718  TRACEresetTime = True # Clear the memory for averaging
4719  elif TRACEmodeTime.get() == 1:
4720  if TRACEresetTime == True:
4721  TRACEresetTime = False
4722  # Save previous trace in memory for average trace
4723  VmemoryA = VBuffA
4724  VmemoryB = VBuffB
4725  ImemoryA = IBuffA
4726  ImemoryB = IBuffB
4727 
4728  try:
4729  HoldOff = float(eval(HoldOffentry.get()))
4730  if HoldOff < 0:
4731  HoldOff = 0
4732  HoldOffentry.delete(0,END)
4733  HoldOffentry.insert(0, HoldOff)
4734  except:
4735  HoldOffentry.delete(0,END)
4736  HoldOffentry.insert(0, HoldOff)
4737 #
4738  try:
4739  HozPoss = float(eval(HozPossentry.get()))
4740  except:
4741  HozPossentry.delete(0,END)
4742  HozPossentry.insert(0, HozPoss)
4743 
4744  hldn = int(HoldOff * SAMPLErate/1000 )
4745  hozpos = int(HozPoss * SAMPLErate/1000 )
4746  if hozpos < 0:
4747  hozpos = 0
4748  twoscreens = int(SAMPLErate * 20.0 * TIMEdiv / 1000.0) # number of samples to acquire, 2 screen widths
4749  onescreen = int(twoscreens/2)
4750  if hldn+hozpos > MaxSamples-twoscreens:
4751  hldn = MaxSamples-twoscreens-hozpos
4752  HoldOffentry.delete(0,END)
4753  HoldOffentry.insert(0, hldn*1000/SAMPLErate)
4754  if ETSDisp.get() > 0:
4755  if TIMEdiv > 0.2:
4756  MaxETSrecord = int(AWGSAMPLErate * 10 * TIMEdiv / 1000.0)
4757  else:
4758  MaxETSrecord = int(AWGSAMPLErate * 20 * TIMEdiv / 1000.0)
4759  if (MaxETSrecord*100) > MaxSamples:
4760  MaxETSrecord = MaxSamples / 100
4761  try:
4762  DivX = float(eval(DivXEntry.get()))
4763  if DivX < 2:
4764  DivX = 2
4765  if DivX > 75:
4766  DivX = 75
4767  DivXEntry.delete(0,END)
4768  DivXEntry.insert(0, DivX)
4769  except:
4770  DivXEntry.delete(0,END)
4771  DivXEntry.insert(0, DivX)
4772  FOff = 25
4773  MulX = (DivX*SAMPLErate)/(100*FOff)
4774  while MulX > MaxETSrecord:
4775  FOff = FOff + 5
4776  MulX = (DivX*SAMPLErate)/(100*FOff)
4777  FOff = 0 - FOff
4778  if DeBugMode > 0:
4779  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
4780  MulXEntry.config(text = SRstring) # change displayed value
4781  SRstring = "Offset = " + str(FOff) + " samples"
4782  FOffEntry.config(text = SRstring) # change displayed value
4783  SHOWsamples = int(MulX * 100)
4784  else:
4785  SHOWsamples = twoscreens + hldn + hozpos
4786  if SHOWsamples > MaxSamples: # or a Max of 100,000 samples
4787  SHOWsamples = MaxSamples
4788  if SHOWsamples < MinSamples: # or a Min of 1000 samples
4789  SHOWsamples = MinSamples
4790  if PhAScreenStatus.get() > 0:
4791  if SHOWsamples < SMPfft:
4792  SHOWsamples = SMPfft + hldn + hozpos
4793  if hozpos >= 0:
4794  TRIGGERsample = hldn
4795  else:
4796  TRIGGERsample = abs(hozpos)
4797  TRIGGERsample = TRIGGERsample + hozpos #
4798 # Starting acquisition
4799  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
4800  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4801  if discontloop > 0:
4802  session.flush()
4803  else:
4804  discontloop = 1
4805  time.sleep(0.01)
4806  BAWGEnab()
4807  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
4808  # waite to finish then return to open termination
4809  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4810  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4811  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4812  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4813  else: # running in continuous mode
4814  if session.continuous:
4815  if MuxScreenStatus.get() > 0:
4816  devx.flush(-1, True)
4817  DummySamples = SHOWsamples*2
4818  if DummySamples < 20000:
4819  DummySamples = 20000
4820  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4821  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
4822  #
4823  else:
4824  ADsignal1 = devx.get_samples(SHOWsamples) # , True) # get samples for both channel A and B
4825  # waite to finish then return to open termination
4826  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4827  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4828  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4829  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4830  #
4831  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4832  if ADC_Mux_Mode.get() == 0: # VA and VB
4833  VBuffA = [] # Clear the V Buff array for trace A
4834  VBuffB = [] # Clear the V Buff array for trace B
4835  elif ADC_Mux_Mode.get() == 1: # IA and IB
4836  IBuffA = [] # Clear the I Buff array for trace A
4837  IBuffB = [] # Clear the I Buff array for trace B
4838  elif ADC_Mux_Mode.get() == 4: # VA and IA
4839  VBuffA = [] # Clear the V Buff array for trace A
4840  IBuffA = [] # Clear the I Buff array for trace A
4841  elif ADC_Mux_Mode.get() == 5: # VB and IB
4842  VBuffB = [] # Clear the V Buff array for trace B
4843  IBuffB = [] # Clear the I Buff array for trace B
4844  else:
4845  VBuffA = [] # Clear the V Buff array for trace A
4846  IBuffA = [] # Clear the I Buff array for trace A
4847  VBuffB = [] # Clear the V Buff array for trace B
4848  IBuffB = [] # Clear the I Buff array for trace B
4849  increment = 1
4850  # SAMPLErate = 200000 #AWGSAMPLErate
4851  if SHOWsamples >= 20000 and DecimateOption.get() > 0:
4852  increment = 2
4853  SAMPLErate = int(AWGSAMPLErate/increment)
4854  if SHOWsamples >= 40000 and DecimateOption.get() > 0:
4855  increment = 4
4856  SAMPLErate = int(AWGSAMPLErate/increment)
4857  index = 0
4858  if SHOWsamples != len(ADsignal1):
4859  SHOWsamples = len(ADsignal1)
4860 #
4861  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0: # check to see if Mux Chop mode is set
4863 #
4864  while index < SHOWsamples: # build arrays and decimate if needed
4865  if Two_X_Sample.get() == 1 and ADC_Mux_Mode.get() < 6:
4866  if ADC_Mux_Mode.get() == 0: # VA and VB
4867  VBuffA.append(ADsignal1[index][0][0])
4868  VBuffA.append(ADsignal1[index][1][1])
4869  VBuffB.append(ADsignal1[index][0][1])
4870  VBuffB.append(ADsignal1[index][1][0])
4871  if Alternate_Sweep_Mode.get() == 0:
4872  IBuffA.append(0.0) # fill as a place holder
4873  IBuffA.append(0.0) # fill as a place holder
4874  IBuffB.append(0.0) # fill as a place holder
4875  IBuffB.append(0.0) # fill as a place holder
4876  elif ADC_Mux_Mode.get() == 1: # IA and IB
4877  IBuffA.append(ADsignal1[index][0][1])
4878  IBuffA.append(ADsignal1[index][1][0])
4879  IBuffB.append(ADsignal1[index][0][0])
4880  IBuffB.append(ADsignal1[index][1][1])
4881  if Alternate_Sweep_Mode.get() == 0:
4882  VBuffA.append(0.0) # fill as a place holder
4883  VBuffA.append(0.0) # fill as a place holder
4884  VBuffB.append(0.0) # fill as a place holder
4885  VBuffB.append(0.0) # fill as a place holder
4886  elif ADC_Mux_Mode.get() == 2: # VA and IB
4887  VBuffA.append((ADsignal1[index][0][1])/1024.0)
4888  VBuffA.append((ADsignal1[index][1][0])/1024.0)
4889  #
4890  IBuffB.append( ((ADsignal1[index][0][0])/4096.0)-0.5 )
4891  IBuffB.append( ((ADsignal1[index][1][1])/4096.0)-0.5 )
4892  #
4893  if Alternate_Sweep_Mode.get() == 0:
4894  VBuffB.append(0.0) # fill as a place holder
4895  VBuffB.append(0.0) # fill as a place holder
4896  IBuffA.append(0.0) # fill as a place holder
4897  IBuffA.append(0.0) # fill as a place holder
4898  elif ADC_Mux_Mode.get() == 3: # VB and IA
4899  VBuffB.append((ADsignal1[index][0][0])/1024.0)
4900  VBuffB.append((ADsignal1[index][1][1])/1024.0)
4901  #
4902  IBuffA.append( ((ADsignal1[index][0][1])/4096.0)-0.5 )
4903  IBuffA.append( ((ADsignal1[index][1][0])/4096.0)-0.5 )
4904  #
4905  if Alternate_Sweep_Mode.get() == 0:
4906  VBuffA.append(0.0) # fill as a place holder
4907  VBuffA.append(0.0) # fill as a place holder
4908  IBuffB.append(0.0) # fill as a place holder
4909  IBuffB.append(0.0) # fill as a place holder
4910  elif ADC_Mux_Mode.get() == 4: # VA and IA
4911  VBuffA.append(ADsignal1[index][0][0])
4912  VBuffA.append(ADsignal1[index][1][1])
4913  IBuffA.append(ADsignal1[index][0][1])
4914  IBuffA.append(ADsignal1[index][1][0])
4915  if Alternate_Sweep_Mode.get() == 0:
4916  VBuffB.append(0.0) # fill as a place holder
4917  VBuffB.append(0.0) # fill as a place holder
4918  IBuffB.append(0.0) # fill as a place holder
4919  IBuffB.append(0.0) # fill as a place holder
4920  elif ADC_Mux_Mode.get() == 5: # VB and IB
4921  VBuffB.append(ADsignal1[index][0][1])
4922  VBuffB.append(ADsignal1[index][1][0])
4923  IBuffB.append(ADsignal1[index][0][0])
4924  IBuffB.append(ADsignal1[index][1][1])
4925  if Alternate_Sweep_Mode.get() == 0:
4926  VBuffA.append(0.0) # fill as a place holder
4927  VBuffA.append(0.0) # fill as a place holder
4928  IBuffA.append(0.0) # fill as a place holder
4929  IBuffA.append(0.0) # fill as a place holder
4930  else:
4931  VBuffA.append(ADsignal1[index][0][0])
4932  IBuffA.append(ADsignal1[index][0][1])
4933  VBuffB.append(ADsignal1[index][1][0])
4934  IBuffB.append(ADsignal1[index][1][1])
4935  index = index + increment
4936 #
4937  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4938  if len(VBuffA) < 4:
4939  index = 0
4940  while index < SHOWsamples:
4941  VBuffA.append(0.0) # fill as a place holder
4942  index = index + increment
4943  if len(VBuffB) < 4:
4944  index = 0
4945  while index < SHOWsamples:
4946  VBuffB.append(0.0) # fill as a place holder
4947  index = index + increment
4948  if len(IBuffA) < 4:
4949  index = 0
4950  while index < SHOWsamples:
4951  IBuffA.append(0.0) # fill as a place holder
4952  index = index + increment
4953  if len(IBuffB) < 4:
4954  index = 0
4955  while index < SHOWsamples:
4956  IBuffB.append(0.0) # fill as a place holder
4957  index = index + increment
4958 #
4959  if ADC_Mux_Mode.get() == 0: # VA and VB
4960  VBuffA = numpy.array(VBuffA)
4961  VBuffB = numpy.array(VBuffB)
4962  VBuffA = (VBuffA - InOffA) * InGainA
4963  VBuffB = (VBuffB - InOffB) * InGainB
4964  ADC_Mux_Mode.set(1) # switch mode
4965  Last_ADC_Mux_Mode = 0
4966  elif ADC_Mux_Mode.get() == 1: # IA and IB
4967  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4968  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4969  IBuffA = (IBuffA - CurOffA) * CurGainA
4970  IBuffB = (IBuffB - CurOffB) * CurGainB
4971  ADC_Mux_Mode.set(Last_ADC_Mux_Mode) # switch mode
4972  elif ADC_Mux_Mode.get() == 4: # VA and IA
4973  VBuffA = numpy.array(VBuffA)
4974  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4975  IBuffA = (IBuffA - CurOffA) * CurGainA
4976  VBuffA = (VBuffA - InOffA) * InGainA
4977  ADC_Mux_Mode.set(1) # switch mode
4978  Last_ADC_Mux_Mode = 4
4979  elif ADC_Mux_Mode.get() == 5: # VB and IB
4980  VBuffB = numpy.array(VBuffB)
4981  VBuffB = (VBuffB - InOffB) * InGainB
4982  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4983  IBuffB = (IBuffB - CurOffB) * CurGainB
4984  ADC_Mux_Mode.set(1) # switch mode
4985  Last_ADC_Mux_Mode = 5
4986  SetADC_Mux()
4987  #
4988  else:
4989  VBuffA = numpy.array(VBuffA)
4990  VBuffB = numpy.array(VBuffB)
4991  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4992  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4993  VBuffA = (VBuffA - InOffA) * InGainA
4994  VBuffB = (VBuffB - InOffB) * InGainB
4995  IBuffA = (IBuffA - CurOffA) * CurGainA
4996  IBuffB = (IBuffB - CurOffB) * CurGainB
4997  TRACESread = 2
4998  SHOWsamples = len(VBuffA)
4999 # temp ETS calculations
5000  if ETSDisp.get() > 0:
5001  baseFreq = SAMPLErate/DivX
5002  #
5003  VAets = []
5004  VBets = []
5005  IAets = []
5006  IBets = []
5007  index = 0
5008  try:
5009  FMul = float(eval(FminEntry.get()))
5010  if FMul < 1:
5011  FMul = 1
5012  FMulXEntry.delete(0,END)
5013  FMulXEntry.insert(0, int(FMul))
5014  if FMul > 75:
5015  FMul = 75
5016  FMulXEntry.delete(0,END)
5017  FMulXEntry.insert(0, int(FMul))
5018  except:
5019  FMulXEntry.delete(0,END)
5020  FMulXEntry.insert(0, int(FMul))
5021  Fmin = baseFreq * FMul
5022  FminE = float(SAMPLErate + FOff)
5023  Samples_Cycle = SAMPLErate/FminE # calculate number of samples per cycle
5024  # length of record set my Multiplcation factor
5025  tot_cycles = int((MulX*100)/Samples_Cycle)
5026  tot_cycles = tot_cycles + 0.1 # number of cycles in record length
5027  ETSrecord = int((MulX*50)/Samples_Cycle)
5028  if tot_cycles > SHOWsamples:
5029  tot_cycles = SHOWsamples-1
5030  # now sort RT data into ETS sample buffers
5031  while index < SHOWsamples:
5032  Ipart, Dpart = divmod( index*Samples_Cycle, 1)
5033  IndexValue = int(tot_cycles * Dpart)
5034  if IndexValue > SHOWsamples:
5035  IndexValue = SHOWsamples-1
5036  if IndexValue > tot_cycles:
5037  IndexValue = tot_cycles
5038  if ETSDir.get() == 0:
5039  VAets.append(VBuffA[IndexValue])
5040  VBets.append(VBuffB[IndexValue])
5041  IAets.append(IBuffA[IndexValue])
5042  IBets.append(IBuffB[IndexValue])
5043  else:
5044  VAets.append(VBuffA[int(tot_cycles-IndexValue)])
5045  VBets.append(VBuffB[int(tot_cycles-IndexValue)])
5046  IAets.append(IBuffA[int(tot_cycles-IndexValue)])
5047  IBets.append(IBuffB[int(tot_cycles-IndexValue)])
5048  index = index + 1
5049  SHiftFact = 5
5050  TimeCorrection = int(SHiftFact ) # correct for 5 uSec CHB time offset
5051  VBuffA = VAets
5052  VBuffB = VBets
5053  IBuffA = IAets
5054  IBuffB = IBets
5055  VBuffA = numpy.array(VBuffA)
5056  VBuffB = numpy.array(VBuffB)
5057  IBuffA = numpy.array(IBuffA)
5058  IBuffB = numpy.array(IBuffB)
5059  try:
5060  TimeCorrection = int(float(eval(ETSts.get())) * TimeCorrection)
5061  except:
5062  TimeCorrection = SHiftFact
5063  if ETSDir.get() == 0:
5064  VBuffB = numpy.roll(VBuffB, TimeCorrection)
5065  IBuffB = numpy.roll(IBuffB, TimeCorrection)
5066  else:
5067  VBuffB = numpy.roll(VBuffB, TimeCorrection)
5068  IBuffB = numpy.roll(IBuffB, TimeCorrection)
5069  SHOWsamples = twoscreens + hldn + hozpos
5070 # Check if Input channel RC high pass compensation checked
5071  if CHA_RC_HP.get() == 1 or CHAI_RC_HP.get() == 1:
5072  try:
5073  TC1A = float(cha_TC1Entry.get())
5074  if TC1A < 0:
5075  TC1A = 0
5076  cha_TC1Entry.delete(0,END)
5077  cha_TC1Entry.insert(0, TC1A)
5078  except:
5079  TC1A = CHA_TC1.get()
5080  try:
5081  TC2A = float(cha_TC2Entry.get())
5082  if TC2A < 0:
5083  TC2A = 0
5084  cha_TC2Entry.delete(0,END)
5085  cha_TC2Entry.insert(0, TC2A)
5086  except:
5087  TC2A = CHA_TC2.get()
5088  #
5089  try:
5090  Gain1A = float(cha_A1Entry.get())
5091  except:
5092  Gain1A = CHA_A1.get()
5093  try:
5094  Gain2A = float(cha_A2Entry.get())
5095  except:
5096  Gain2A = CHA_A2.get()
5097  #
5098  if len(VBuffA) > 4:
5099  VBuffA = Digital_RC_High_Pass( VBuffA, TC1A, Gain1A )
5100  VBuffA = Digital_RC_High_Pass( VBuffA, TC2A, Gain2A )
5101  if CHAI_RC_HP.get() == 1:
5102  IBuffA = Digital_RC_High_Pass( IBuffA, TC1A, Gain1A )
5103  #IBuffA = Digital_RC_High_Pass( IBuffA, TC2A, Gain2A )
5104  if CHB_RC_HP.get() == 1 or CHBI_RC_HP.get() == 1:
5105  try:
5106  TC1B = float(chb_TC1Entry.get())
5107  if TC1B < 0:
5108  TC1B = 0
5109  chb_TC1Entry.delete(0, END)
5110  chb_TC1Entry.insert(0, TC1B)
5111  except:
5112  TC1B = CHB_TC1.get()
5113  try:
5114  TC2B = float(chb_TC2Entry.get())
5115  if TC2B < 0:
5116  TC2B = 0
5117  chb_TC2Entry.delete(0, END)
5118  chb_TC2Entry.insert(0, TC2B)
5119  except:
5120  TC2B = CHB_TC2.get()
5121  #
5122  try:
5123  Gain1B = float(chb_A1Entry.get())
5124  except:
5125  Gain1B = CHB_A1.get()
5126  try:
5127  Gain2B = float(chb_A2Entry.get())
5128  except:
5129  Gain2B = CHB_A2.get()
5130  #
5131  if len(VBuffB) > 4:
5132  VBuffB = Digital_RC_High_Pass( VBuffB, TC1B, Gain1B )
5133  VBuffB = Digital_RC_High_Pass( VBuffB, TC2B, Gain2B )
5134  if CHBI_RC_HP.get() == 1:
5135  IBuffB = Digital_RC_High_Pass( IBuffB, TC1B, Gain1B )
5136  #IBuffB = Digital_RC_High_Pass( IBuffB, TC2B, Gain2B )
5137 # Check if need to DeSkew waveform data
5138  if DigDeSkewVA.get() > 0:
5139  Shift = int(BCVASkewEntry.get())
5140  if Shift != 0:
5141  VBuffA = numpy.roll(VBuffA, Shift)
5142  if DigDeSkewVB.get() > 0:
5143  Shift = int(BCVBSkewEntry.get())
5144  if Shift != 0:
5145  VBuffB = numpy.roll(VBuffB, Shift)
5146  if DigDeSkewIA.get() > 0:
5147  Shift = int(BCIASkewEntry.get())
5148  if Shift != 0:
5149  IBuffA = numpy.roll(IBuffA, Shift)
5150  if DigDeSkewIB.get() > 0:
5151  Shift = int(BCIBSkewEntry.get())
5152  if Shift != 0:
5153  IBuffB = numpy.roll(IBuffB, Shift)
5154 # check if digital filter box checked
5155  if DigFiltA.get() == 1:
5156  if len(DFiltACoef) > 1:
5157  VBuffA = numpy.convolve(VBuffA, DFiltACoef)
5158  if DigFiltB.get() == 1:
5159  if len(DFiltBCoef) > 1:
5160  VBuffB = numpy.convolve(VBuffB, DFiltBCoef)
5161 # Find trigger sample point if necessary
5162  LShift = 0
5163  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0:
5164  if ChopTrig.get() == 1:
5165  FindTriggerSample(VBuffMA)
5166  if ChopTrig.get() == 2:
5167  FindTriggerSample(VBuffMB)
5168  if ChopTrig.get() == 3:
5169  FindTriggerSample(VBuffMC)
5170  if ChopTrig.get() == 4:
5171  FindTriggerSample(VBuffMD)
5172  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5173  # Average mode 1, add difference / TRACEaverage to array
5174  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0:
5175  LShift = 0 - TRIGGERsample
5176  VBuffMA = numpy.roll(VBuffMA, LShift)
5177  VBuffMB = numpy.roll(VBuffMB, LShift)
5178  VBuffMC = numpy.roll(VBuffMC, LShift)
5179  VBuffMD = numpy.roll(VBuffMD, LShift)
5180  IBuffA = numpy.roll(IBuffA, LShift)
5181  IBuffB = numpy.roll(IBuffB, LShift)
5182  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
5183  if ChopTrig.get() == 1:
5184  ReInterploateTrigger(VBuffMA)
5185  if ChopTrig.get() == 2:
5186  ReInterploateTrigger(VBuffMB)
5187  if ChopTrig.get() == 3:
5188  ReInterploateTrigger(VBuffMC)
5189  if ChopTrig.get() == 4:
5190  ReInterploateTrigger(VBuffMD)
5191  else:
5192  if TgInput.get() == 1:
5193  FindTriggerSample(VBuffA)
5194  if TgInput.get() == 2:
5195  FindTriggerSample(IBuffA)
5196  if TgInput.get() == 3:
5197  FindTriggerSample(VBuffB)
5198  if TgInput.get() == 4:
5199  FindTriggerSample(IBuffB)
5200  if TgInput.get() == 5:
5201  FindTriggerSample(VBuffA)
5202  if Is_Triggered == 0: # Trigger event not found for VBuffA so Try VBuffB
5203  FindTriggerSample(VBuffB)
5204  if TgInput.get() == 6:
5205  FindTriggerSample(VBuffA)
5206  TRIGGERsampleAltA = TRIGGERsample
5207  FindTriggerSample(VBuffB)
5208  TRIGGERsampleAltB = TRIGGERsample
5209  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5210  # Average mode 1, add difference / TRACEaverage to array
5211  if TgInput.get() > 0: # if triggering left shift all arrays such that trigger point is at index 0
5212  LShift = 0 - TRIGGERsample
5213  if TgInput.get() == 6:
5214  LShift = 0 - TRIGGERsampleAltA
5215  VBuffA = numpy.roll(VBuffA, LShift)
5216  IBuffA = numpy.roll(IBuffA, LShift)
5217  LShift = 0 - TRIGGERsampleAltB
5218  VBuffB = numpy.roll(VBuffB, LShift)
5219  IBuffB = numpy.roll(IBuffB, LShift)
5220  else:
5221  VBuffA = numpy.roll(VBuffA, LShift)
5222  VBuffB = numpy.roll(VBuffB, LShift)
5223  IBuffA = numpy.roll(IBuffA, LShift)
5224  IBuffB = numpy.roll(IBuffB, LShift)
5225  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
5226  if UnAvgSav.get() == 1: # copy un averaged trace to buffer
5227  VUnAvgA = VBuffA
5228  VUnAvgB = VBuffB
5229  IUnAvgA = IBuffA
5230  IUnAvgB = IBuffB
5231  try:
5232  if DualMuxMode.get() == 0: # and MuxScreenStatus.get() == 0: # average A voltage data only if not in dual split I/O Mux Mode
5233  VBuffA = VmemoryA + (VBuffA - VmemoryA) / TRACEaverage.get()
5234  IBuffA = ImemoryA + (IBuffA - ImemoryA) / TRACEaverage.get()
5235  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
5236  VBuffB = VmemoryB + (VBuffB - VmemoryB) / TRACEaverage.get()
5237  IBuffB = ImemoryB + (IBuffB - ImemoryB) / TRACEaverage.get()
5238  except:
5239  # buffer size mismatch so reset memory buffers
5240  VmemoryA = VBuffA
5241  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
5242  VmemoryB = VBuffB
5243  ImemoryA = IBuffA
5244  ImemoryB = IBuffB
5245  if TgInput.get() == 1 or TgInput.get() == 5 or TgInput.get() == 6:
5246  ReInterploateTrigger(VBuffA)
5247  if TgInput.get() == 2:
5248  ReInterploateTrigger(IBuffA)
5249  if TgInput.get() == 3 or TgInput.get() == 5 or TgInput.get() == 6:
5250  ReInterploateTrigger(VBuffB)
5251  if TgInput.get() == 4:
5252  ReInterploateTrigger(IBuffB)
5253 # DC value = average of the data record
5254  if CHA_RC_HP.get() == 1 or CHB_RC_HP.get() == 1:
5255  Endsample = hldn+onescreen # average over only one screen's worth of samples
5256  else:
5257  Endsample = SHOWsamples - 10 # average over all samples
5258  if MeasGateStatus.get() == 1:
5259  if (MeasGateRight-MeasGateLeft) > 0:
5260  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
5261  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
5262  if Endsample <= hldn:
5263  Endsample = hldn + 2
5264 # Calculate scalar values
5265  Cal_trace_scalars(hldn, Endsample)
5266 # Transfer to mux buffers as necessary
5267  if TgInput.get() > 0 and TRACEmodeTime.get() != 1: # and MuxChan > -1
5268  # if triggering left shift all arrays such that trigger point is at index 0
5269  LShift = 0 - TRIGGERsample
5270  VBuffA = numpy.roll(VBuffA, LShift)
5271  VBuffB = numpy.roll(VBuffB, LShift)
5272  IBuffA = numpy.roll(IBuffA, LShift)
5273  IBuffB = numpy.roll(IBuffB, LShift)
5274  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
5275  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0 and TRACEmodeTime.get() != 1:
5276  LShift = 0 - TRIGGERsample
5277  VBuffMA = numpy.roll(VBuffMA, LShift)
5278  VBuffMB = numpy.roll(VBuffMB, LShift)
5279  VBuffMC = numpy.roll(VBuffMC, LShift)
5280  VBuffMD = numpy.roll(VBuffMD, LShift)
5281  IBuffA = numpy.roll(IBuffA, LShift)
5282  IBuffB = numpy.roll(IBuffB, LShift)
5283  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
5284  if ChopMuxMode.get() == 1 and TRACEmodeTime.get() == 1: # also if in chop mode cal avaerage
5285  # Average mode 1, add difference / TRACEaverage to array
5286  try:
5287  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
5288  except: # buffer size mismatch so reset memory buffers
5289  VmemoryMuxA = VBuffMA
5290  try:
5291  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
5292  except: # buffer size mismatch so reset memory buffers
5293  VmemoryMuxB = VBuffMB
5294  try:
5295  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
5296  except: # buffer size mismatch so reset memory buffers
5297  VmemoryMuxC = VBuffMC
5298  try:
5299  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
5300  except: # buffer size mismatch so reset memory buffers
5301  VmemoryMuxD = VBuffMD
5302  if MuxChan > -1 and ChopMuxMode.get() == 0: # do this when not in chop mux mode
5303  if Show_CBA.get() == 1 and MuxChan == 0: # Dval0[0] == 0 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
5304  DCVMuxA = DCV2
5305  MinVMuxA = MinV2
5306  MaxVMuxA = MaxV2
5307  MidVMuxA = (MaxV2+MinV2)/2.0
5308  PPVMuxA = MaxV2-MinV2
5309  SVMuxA = SV2
5310  VBuffMA = VBuffB
5311  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5312  # Average mode 1, add difference / TRACEaverage to array
5313  try:
5314  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
5315  except:
5316  # buffer size mismatch so reset memory buffers
5317  VmemoryMuxA = VBuffMA
5318  if Show_CBB.get() == 1 and MuxChan == 1: # Dval0[0] == 1 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
5319  DCVMuxB = DCV2
5320  MinVMuxB = MinV2
5321  MaxVMuxB = MaxV2
5322  MidVMuxB = (MaxV2+MinV2)/2.0
5323  PPVMuxB = MaxV2-MinV2
5324  SVMuxB = SV2
5325  VBuffMB = VBuffB
5326  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5327  # Average mode 1, add difference / TRACEaverage to array
5328  try:
5329  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
5330  except:
5331  # buffer size mismatch so reset memory buffers
5332  VmemoryMuxB = VBuffMB
5333  if Show_CBC.get() == 1 and MuxChan == 2: #and Dval0[0] == 0 and Dval1[0] == 1
5334  if DualMuxMode.get() == 1 :
5335  DCVMuxC = DCV1
5336  MinVMuxC = MinV1
5337  MaxVMuxC = MaxV1
5338  MidVMuxC = (MaxV1+MinV1)/2.0
5339  PPVMuxC = MaxV1-MinV1
5340  SVMuxC = SV1
5341  VBuffMC = VBuffA
5342  else:
5343  DCVMuxC = DCV2
5344  MinVMuxC = MinV2
5345  MaxVMuxC = MaxV2
5346  MidVMuxC = (MaxV2+MinV2)/2.0
5347  PPVMuxC = MaxV2-MinV2
5348  SVMuxC = SV2
5349  VBuffMC = VBuffB
5350  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5351  # Average mode 1, add difference / TRACEaverage to array
5352  try:
5353  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
5354  except:
5355  # buffer size mismatch so reset memory buffers
5356  VmemoryMuxC = VBuffMC
5357  if Show_CBD.get() == 1 and MuxChan == 3: #and Dval0[0] == 1 and Dval1[0] == 1
5358  if DualMuxMode.get() == 1 :
5359  DCVMuxD = DCV1
5360  MinVMuxD = MinV1
5361  MaxVMuxD = MaxV1
5362  MidVMuxD = (MaxV1+MinV1)/2.0
5363  PPVMuxD = MaxV1-MinV1
5364  SVMuxD = SV1
5365  VBuffMD = VBuffA
5366  else:
5367  DCVMuxD = DCV2
5368  MinVMuxD = MinV2
5369  MaxVMuxD = MaxV2
5370  MidVMuxD = (MaxV2+MinV2)/2.0
5371  PPVMuxD = MaxV2-MinV2
5372  SVMuxD = SV2
5373  VBuffMD = VBuffB
5374  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5375  # Average mode 1, add difference / TRACEaverage to array
5376  try:
5377  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
5378  except:
5379  # buffer size mismatch so reset memory buffers
5380  VmemoryMuxD = VBuffMD
5381  # update screens
5382  if TimeDisp.get() > 0:
5383  # Check if in non functional state of 2X samplerate and 3 or more traces and not enabled AWGSync
5384  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
5385  if NumTraces > 2 and AWGSync.get() == 0 and Two_X_Sample.get() == 1:
5386  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
5387  BStop()
5388  # return
5389  UpdateTimeAll() # Update Data, trace and time screen
5390  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
5391  UpdateXYAll() # Update Data, trace and XY screen
5392  if SingleShot.get() > 0 and Is_Triggered == 1: # Singel Shot trigger is on
5393  BStop() #
5394  SingleShot.set(0)
5395  if ManualTrigger.get() == 1: # Manual trigger is on
5396  BStop() #
5397  if MeasureStatus.get() > 0:
5399 #
5400 # Calculate waveform scalar values
5401 def Cal_trace_scalars(SampleStart, SampleEnd):
5402  global VBuffA, VBuffB, IBuffA, IBuffB
5403  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5404  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5405  global SV1, SI1, SV2, SI2, SVA_B
5406 
5407  DCV1 = numpy.mean(VBuffA[SampleStart:SampleEnd])
5408  DCV2 = numpy.mean(VBuffB[SampleStart:SampleEnd])
5409  DCI1 = numpy.mean(IBuffA[SampleStart:SampleEnd])
5410  DCI2 = numpy.mean(IBuffB[SampleStart:SampleEnd])
5411 # find min and max values
5412  MinV1 = numpy.amin(VBuffA[SampleStart:SampleEnd])
5413  MaxV1 = numpy.amax(VBuffA[SampleStart:SampleEnd])
5414  MinV2 = numpy.amin(VBuffB[SampleStart:SampleEnd])
5415  MaxV2 = numpy.amax(VBuffB[SampleStart:SampleEnd])
5416  MinI1 = numpy.amin(IBuffA[SampleStart:SampleEnd])
5417  MaxI1 = numpy.amax(IBuffA[SampleStart:SampleEnd])
5418  MinI2 = numpy.amin(IBuffB[SampleStart:SampleEnd])
5419  MaxI2 = numpy.amax(IBuffB[SampleStart:SampleEnd])
5420 # RMS value = square root of average of the data record squared
5421  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA[SampleStart:SampleEnd])))
5422  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA[SampleStart:SampleEnd])))
5423  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB[SampleStart:SampleEnd])))
5424  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB[SampleStart:SampleEnd])))
5425  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA[SampleStart:SampleEnd]-VBuffB[SampleStart:SampleEnd])))
5426 #
5427 # Function to calculate relative phase angle between two sine waves of the same frequency
5428 # Removes any DC content
5429 def Sine_Phase():
5430  global DCV1, DCV2, VBuffA, VBuffB
5431 
5432  sum1 = 0.0
5433  sum2 = 0.0
5434  sum12 = 0.0
5435  i = 0
5436  n = len(VBuffA)
5437  while i < n:
5438  sum1 += (VBuffA[i]-DCV1)*(VBuffA[i]-DCV1)
5439  sum2 += (VBuffB[i]-DCV2)*(VBuffB[i]-DCV2)
5440  sum12 += (VBuffA[i]-DCV1)*(VBuffB[i]-DCV2)
5441  i += 1
5442  return math.acos(sum12/math.sqrt(sum1*sum2))*180.0/numpy.pi
5443 #
5444 # High Pass y[n] = alpha * (y[n-1] + x[n] - x[n-1])
5445 # Low Pass y[n] = y[n-1] + (alpha * ((x[n] - x[n-1]))
5446 # All Pass y[n] = alpha * y[n-1] - alpha * (x[n] + x[n-1])
5447 # All Pass y[n] = alpha * (y[n-1] - x[n] - x[n-1])
5448 
5449 
5451 def Digital_RC_High_Pass( InBuff, TC1, Gain ):
5452  global SAMPLErate, Two_X_Sample
5453 
5454  OutBuff = []
5455  n = len(InBuff)
5456  if Two_X_Sample.get() == 0:
5457  Delta = 1.0/SAMPLErate
5458  else: # adjust for sligh difference in 2X sample mode?
5459  Delta = 0.88/SAMPLErate
5460  TC = TC1 * 1.0E-6
5461  Alpha = TC / (TC + Delta)
5462  OutBuff.append(0.0) # initialize first output sample
5463  i = 1
5464  while i < n:
5465  OutBuff.append( Alpha * (OutBuff[i-1] + InBuff[i] - InBuff[i-1]) )
5466  i += 1
5467  OutBuff = numpy.array(OutBuff)
5468  OutBuff = InBuff + (OutBuff * Gain)
5469  return OutBuff
5470 
5472 def Digital_RC_Low_Pass( InBuff, TC1, Gain ): # TC1 is in micro seconds
5473  global SAMPLErate
5474 
5475  OutBuff = []
5476  n = len(InBuff)
5477  Delta = 1.0/SAMPLErate
5478  TC = TC1 * 1.0E-6
5479  Alpha = Delta / (TC + Delta)
5480  i = 1
5481  OutBuff.append(Alpha*InBuff[0])
5482  while i < n:
5483  OutBuff.append( OutBuff[i-1] + (Alpha * (InBuff[i] - InBuff[i-1])) )
5484  i += 1
5485  OutBuff = numpy.array(OutBuff)
5486  OutBuff = (OutBuff * Gain)
5487  return OutBuff
5488 
5492 def shift_buffer(arr, num, fill_value=numpy.nan):
5493  result = numpy.empty_like(arr)
5494  if num > 0:
5495  result[:num] = fill_value
5496  result[num:] = arr[:-num]
5497  elif num < 0:
5498  result[num:] = fill_value
5499  result[:num] = arr[-num:]
5500  else:
5501  result[:] = arr
5502  return result
5503 
5504 
5506 def Analog_Freq_In():
5507  global ADsignal1, FFTBuffA, FFTBuffB, SMPfft
5508  global AWGSync, AWGAMode, AWGBMode, AWGAShape, AWGAIOMode, AWGBIOMode
5509  global AWGAFreqvalue, AWGBFreqvalue, FStepSync, FSweepSync
5510  global NSteps, LoopNum, FSweepMode, FStep, FBins
5511  global StartFreqEntry, StopFreqEntry, HoldOffentry
5512  global session, CHA, CHB, devx, MaxSamples, discontloop
5513  global RUNstatus, SingleShotSA, FSweepCont, Two_X_Sample, ADC_Mux_Mode
5514  global AWGSAMPLErate, IAScreenStatus, SpectrumScreenStatus, BodeScreenStatus
5515  global NiCScreenStatus, NiCDisp, NqPScreenStatus, NqPDisp
5516  global OverRangeFlagA, OverRangeFlagB, BodeDisp, FreqDisp, IADisp
5517  global DCA, DCB, InOffA, InGainA, InOffB, InGainB
5518  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
5519  global DigFiltA, DFiltACoef, DigFiltB, DFiltBCoef
5520  global BDSweepFile, FileSweepFreq, FileSweepAmpl
5521  global PIO_0, PIO_1, PIO_2, PIO_3
5522  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
5523  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
5524  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
5525  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
5526  global Reset_Freq, AWGAFreqEntry, AWGBFreqEntry, MinigenFout, IASource, IA_Ext_Conf
5527 
5528  HalfSAMPLErate = SAMPLErate/2
5529  # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
5530  try:
5531  InOffA = float(eval(CHAVOffsetEntry.get()))
5532  except:
5533  CHAVOffsetEntry.delete(0,END)
5534  CHAVOffsetEntry.insert(0, InOffA)
5535  try:
5536  InGainA = float(eval(CHAVGainEntry.get()))
5537  except:
5538  CHAVGainEntry.delete(0,END)
5539  CHAVGainEntry.insert(0, InGainA)
5540  try:
5541  InOffB = float(eval(CHBVOffsetEntry.get()))
5542  except:
5543  CHBVOffsetEntry.delete(0,END)
5544  CHBVOffsetEntry.insert(0, InOffB)
5545  try:
5546  InGainB = float(eval(CHBVGainEntry.get()))
5547  except:
5548  CHBVGainEntry.delete(0,END)
5549  CHBVGainEntry.insert(0, InGainB)
5550  try:
5551  HoldOff = float(eval(HoldOffentry.get()))
5552  if HoldOff < 0:
5553  HoldOff = 0
5554  HoldOffentry.delete(0,END)
5555  HoldOffentry.insert(0, HoldOff)
5556  except:
5557  HoldOffentry.delete(0,END)
5558  HoldOffentry.insert(0, HoldOff)
5559  #
5560  INITIALIZEstart()
5561  # Starting acquisition This is a HACK to get around non-continous AWG mode!
5562  # restart AWGs if indicated
5563  if BodeDisp.get() == 0: # make new noise waveforms each sweep
5564  if AWGAShape.get() == 7 and AWGAMode.get() == 0:
5565  AWGAMakeUUNoise()
5566  elif AWGAShape.get() == 8 and AWGAMode.get() == 0:
5567  AWGAMakeUGNoise()
5568  elif AWGBShape.get() == 7 and AWGBMode.get() == 0:
5569  AWGBMakeUUNoise()
5570  elif AWGBShape.get() == 8 and AWGBMode.get() == 0:
5571  AWGBMakeUGNoise()
5572  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Run Sweep Gen only if sleceted and Bode display is active
5573  if BDSweepFile.get() == 0:
5574  if LoopNum.get() <= len(FStep):
5575  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
5576  else:
5577  FregPoint = FBins[FStep[0]]
5578  else:
5579  if LoopNum.get() <= len(FileSweepFreq): #
5580  FreqIndex = int((FileSweepFreq[LoopNum.get()-1]*16384)/HalfSAMPLErate)
5581  FregPoint = FBins[FreqIndex] # look up next frequency from list of bins
5582  VRMSAmpl = 10**(FileSweepAmpl[LoopNum.get()-1]/20) # convert to V RMS 0 dBV = 1V RMS
5583  else:
5584  FregPoint = FBins[FileSweepFreq[0]]
5585  VRMSAmpl = 10**(FileSweepAmpl[0]/20) # convert to V RMS 0 dBV = 1V RMS
5586  VMax = 2.5 + (1.414*VRMSAmpl) # calculate positive peak assuming sine wave
5587  VMin = 2.5 - (1.414*VRMSAmpl) # calculate negative peak assuming sine wave
5588  if FSweepMode.get() == 1: # set new CH-A amplitude
5589  AWGAAmplEntry.delete(0,END)
5590  AWGAAmplEntry.insert(4, VMin)
5591  AWGAOffsetEntry.delete(0,END)
5592  AWGAOffsetEntry.insert(4, VMax)
5593  if FSweepMode.get() == 2: # set new CH-B amplitude
5594  AWGBAmplEntry.delete(0,END)
5595  AWGBAmplEntry.insert(4, VMin)
5596  AWGBOffsetEntry.delete(0,END)
5597  AWGBOffsetEntry.insert(4, VMax)
5598  if FSweepMode.get() == 1: # set new CH-A frequency
5599  AWGAFreqEntry.delete(0,END)
5600  AWGAFreqEntry.insert(4, FregPoint)
5602  if FSweepMode.get() == 2: # set new CH-B frequency
5603  AWGBFreqEntry.delete(0,END)
5604  AWGBFreqEntry.insert(4, FregPoint)
5606  if FSweepMode.get() == 3: # set new MiniGen frequency
5607  MinigenFout.delete(0,END)
5608  MinigenFout.insert(4, FregPoint)
5609  BSendMG()
5610  if AWGSync.get() > 0:
5611  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5612  if Two_X_Sample.get() == 1:
5613  AWGBIOMode.set(1)
5614  AWGBMode.set(0)
5615  else:
5616  AWGBMode.set(2)
5617  # BAWGEnab()
5618 #
5619  hldn = int(HoldOff * 100 )
5620  if hldn > MaxSamples-SMPfft:
5621  hldn = MaxSamples-SMPfft
5622  HoldOffentry.delete(0,END)
5623  HoldOffentry.insert(0, hldn/100)
5624  if hldn < 128:
5625  hldn = 128
5626  SHOWsamples = SMPfft + hldn # get holf off extra samples
5627  if BodeDisp.get() > 0: # check if doing Bode Plot
5628  if FStepSync.get() == 1: # output low - high - low pulse on PIO-0
5629  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5630  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5631  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5632  if FStepSync.get() == 2: # output high - low - high pulse on PIO-0
5633  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5634  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5635  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5636  if LoopNum.get() == 1 and FSweepSync.get() == 1: # output low - high - low pulse on PIO-1
5637  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5638  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5639  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5640  if LoopNum.get() == 1 and FSweepSync.get() == 2: # output high - low - high pulse on PIO-1
5641  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5642  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5643  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5644  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
5645  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5646  if Two_X_Sample.get() == 1:
5647  AWGBIOMode.set(1)
5648  AWGBMode.set(0)
5649  else:
5650  AWGBMode.set(2)
5651  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
5652  if discontloop > 0:
5653  session.flush()
5654  else:
5655  discontloop = 1
5656  BAWGEnab()
5657  try:
5658  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5659  except:
5660  donothing()
5661  # waite to finish then return to open termination
5662  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5663  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5664  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5665  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5666  else: # running in continuous mode
5667  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
5668  #
5669  else:
5670  if session.continuous:
5671  ADsignal1 = devx.read(SHOWsamples, -1, True)
5672  # ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5673  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5674  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5675  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5676  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5677  FFTBuffA = [] # Clear the FFTBuff array for trace A
5678  FFTBuffB = [] # Clear the FFTBuff array for trace B
5679  OverRangeFlagA = OverRangeFlagB = 0 # Clear over range flags
5680  index = hldn # skip first hldn samples
5681  if SHOWsamples != len(ADsignal1):
5682  SHOWsamples = len(ADsignal1)
5683  while index < SHOWsamples:
5684  if Two_X_Sample.get() == 1:
5685  if ADC_Mux_Mode.get() == 0: # VA and VB
5686  FFTBuffA.append(ADsignal1[index][0][0])
5687  FFTBuffA.append(ADsignal1[index][1][1])
5688  FFTBuffB.append(ADsignal1[index][0][1])
5689  FFTBuffB.append(ADsignal1[index][1][0])
5690  else:
5691  VAdata = ADsignal1[index][0][0]
5692  FFTBuffA.append(VAdata)
5693  VBdata = ADsignal1[index][1][0]
5694  FFTBuffB.append(VBdata)
5695  if VAdata > 5.0 or VAdata < 0.0:
5696  OverRangeFlagA = 1
5697 
5698  if VBdata > 5.0 or VBdata < 0.0:
5699  OverRangeFlagB = 1
5700  index = index + 1
5701 
5702  FFTBuffA = numpy.array(FFTBuffA)
5703  FFTBuffB = numpy.array(FFTBuffB)
5704  FFTBuffA = (FFTBuffA - InOffA) * InGainA
5705  FFTBuffB = (FFTBuffB - InOffB) * InGainB
5706  DCA = numpy.average(FFTBuffA)
5707  DCB = numpy.average(FFTBuffB)
5708  if CutDC.get() == 1:
5709  FFTBuffA = FFTBuffA - DCA
5710  FFTBuffB = FFTBuffB - DCB
5711 # Check if Input channel RC high pass compensation checked cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
5712  if CHA_RC_HP.get() == 1:
5713  try:
5714  TC1A = float(cha_TC1Entry.get())
5715  if TC1A < 0:
5716  TC1A = 0
5717  cha_TC1Entry.delete(0,END)
5718  cha_TC1Entry.insert(0, TC1A)
5719  except:
5720  TC1A = CHA_TC1.get()
5721  try:
5722  TC2A = float(cha_TC2Entry.get())
5723  if TC2A < 0:
5724  TC2A = 0
5725  cha_TC2Entry.delete(0,END)
5726  cha_TC2Entry.insert(0, TC2A)
5727  except:
5728  TC2A = CHA_TC2.get()
5729  #
5730  try:
5731  Gain1A = float(cha_A1Entry.get())
5732  except:
5733  Gain1A = CHA_A1.get()
5734  try:
5735  Gain2A = float(cha_A2Entry.get())
5736  except:
5737  Gain2A = CHA_A2.get()
5738  #
5739  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC1A, Gain1A )
5740  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC2A, Gain2A )
5741  if CHB_RC_HP.get() == 1:
5742  try:
5743  TC1B = float(chb_TC1Entry.get())
5744  if TC1B < 0:
5745  TC1B = 0
5746  chb_TC1Entry.delete(0, END)
5747  chb_TC1Entry.insert(0, TC1B)
5748  except:
5749  TC1B = CHB_TC1.get()
5750  try:
5751  TC2B = float(chb_TC2Entry.get())
5752  if TC2B < 0:
5753  TC2B = 0
5754  chb_TC2Entry.delete(0, END)
5755  chb_TC2Entry.insert(0, TC2B)
5756  except:
5757  TC2B = CHB_TC2.get()
5758  #
5759  try:
5760  Gain1B = float(chb_A1Entry.get())
5761  except:
5762  Gain1B = CHB_A1.get()
5763  try:
5764  Gain2B = float(chb_A2Entry.get())
5765  except:
5766  Gain2B = CHB_A2.get()
5767  #
5768  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC1B, Gain1B )
5769  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC2B, Gain2B )
5770 # check if digital filter box checked
5771  if DigFiltA.get() == 1:
5772  FFTBuffA = numpy.convolve(FFTBuffA, DFiltACoef)
5773  if DigFiltB.get() == 1:
5774  FFTBuffB = numpy.convolve(FFTBuffB, DFiltBCoef)
5775  DoFFT()
5776  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
5777  UpdateFreqAll() # Update spectrum Data, trace and screen
5778  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
5779  UpdateIAAll()
5780  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
5781  UpdateBodeAll()
5782  if NqPScreenStatus.get() > 0 and NqPDisp.get() > 0:
5783  UpdateNqPAll()
5784  if NiCScreenStatus.get() > 0 and NiCDisp.get() > 0:
5785  UpdateNiCAll()
5786  if SingleShotSA.get() == 1: # Single shot sweep is on
5787  RUNstatus.set(0)
5788 #
5789  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Increment loop counter only if sleceted and Bode display is active
5790  LoopNum.set(LoopNum.get() + 1)
5791  if LoopNum.get() > NSteps.get():
5792  if FSweepMode.get() == 1:
5793  AWGAFreqEntry.delete(0,"end")
5794  AWGAFreqEntry.insert(0, Reset_Freq)
5795  if FSweepMode.get() == 2:
5796  AWGBFreqEntry.delete(0,"end")
5797  AWGBFreqEntry.insert(0, Reset_Freq)
5798 #
5799  LoopNum.set(1)
5800  if FSweepCont.get() == 0:
5801  RUNstatus.set(0)
5802 #
5803 
5804 def MakeHistogram():
5805  global VBuffA, VBuffB, IBuffA, IBuffB, HBuffA, HBuffB
5806  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
5807  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Xsignal
5808  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5809  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5810  global VABase, VATop, VBBase, VBTop
5811 
5812  if ShowC1_V.get() == 1 or Xsignal.get() == 6:
5813  CHAGridMax = (5 * CH1pdvRange ) + CHAOffset # Calculate CHA Grid Min and Max
5814  CHAGridMin = (-5 * CH1pdvRange ) + CHAOffset
5815  VAMid = (MinV1 + MaxV1)/2 # Find CHA mid value
5816  HBuffA = numpy.histogram(VBuffA, bins=5000, range=[CHAGridMin, CHAGridMax] )
5817  LowerPeak = 0
5818  UpperPeak = 0
5819  b = 0
5820  while (b < 4999):
5821  if HBuffA[0][b] > HBuffA[0][LowerPeak] and HBuffA[1][b] < VAMid:
5822  LowerPeak = b
5823  VABase = HBuffA[1][b]
5824  if HBuffA[0][b] > HBuffA[0][UpperPeak] and HBuffA[1][b] > VAMid:
5825  UpperPeak = b
5826  VATop = HBuffA[1][b]
5827  b = b + 1
5828  if ShowC2_V.get() == 1 or Xsignal.get() == 7:
5829  CHBGridMax = (5 * CH2pdvRange ) + CHBOffset # Calculate CHB Grid Min and Max
5830  CHBGridMin = (-5 * CH2pdvRange ) + CHBOffset
5831  VBMid = (MinV2 + MaxV2)/2 # Find CHB mid value
5832  HBuffB = numpy.histogram(VBuffB, bins=5000, range=[CHBGridMin, CHBGridMax] )
5833  LowerPeak = 0
5834  UpperPeak = 0
5835  b = 0
5836  while (b < 4999):
5837  if HBuffB[0][b] > HBuffB[0][LowerPeak] and HBuffB[1][b] < VBMid:
5838  LowerPeak = b
5839  VBBase = HBuffB[1][b]
5840  if HBuffB[0][b] > HBuffB[0][UpperPeak] and HBuffB[1][b] > VBMid:
5841  UpperPeak = b
5842  VBTop = HBuffB[1][b]
5843  b = b + 1
5844 
5845 def BHistAsPercent():
5846  global HistAsPercent
5847 
5848  if askyesno("Plot as Percent", "Plot Histogram as Percent?", parent=xywindow):
5849  HistAsPercent = 1
5850  else:
5851  HistAsPercent = 0
5852 
5853 def FindRisingEdge(Trace1, Trace2):
5854  global MinV1, MaxV1, MinV2, MaxV2, HoldOff, TRIGGERsample, TgInput, LShift
5855  global ETSrecord, DISsamples
5856  global SHOWsamples, SAMPLErate, CHAperiod, CHAfreq, CHBperiod, CHBfreq
5857  global CHAHW, CHALW, CHADCy, CHBHW, CHBLW, CHBDCy, ShowC1_V, ShowC2_V
5858  global CHABphase, CHBADelayR1, CHBADelayR2, CHBADelayF
5859 
5860  anr1 = bnr1 = 0
5861  anf1 = bnf1 = 1
5862  anr2 = bnr2 = 2
5863  hldn = int(HoldOff * SAMPLErate/1000)
5864  # print(DISsamples, len(Trace1))
5865  if TgInput.get() > 0: # if triggering right shift arrays to undo trigger left shift
5866  Trace1 = numpy.roll(Trace1, -LShift)
5867  Trace2 = numpy.roll(Trace2, -LShift)
5868  else:
5869  Trace1 = numpy.roll(Trace1, -hldn)
5870  Trace2 = numpy.roll(Trace2, -hldn)
5871  try:
5872  MidV1 = (numpy.amax(Trace1)+numpy.amin(Trace1))/2.0
5873  MidV2 = (numpy.amax(Trace2)+numpy.amin(Trace2))/2.0
5874  except:
5875  MidV1 = (MinV1+MaxV1)/2
5876  MidV2 = (MinV2+MaxV2)/2
5877 # search Trace 1
5878 
5885  Arising = [i for (i, val) in enumerate(Trace1) if val >= MidV1 and Trace1[i-1] < MidV1]
5886  Afalling = [i for (i, val) in enumerate(Trace1) if val <= MidV1 and Trace1[i-1] > MidV1]
5887  AIrising = [i - (Trace1[i] - MidV1)/(Trace1[i] - Trace1[i-1]) for i in Arising]
5888  AIfalling = [i - (MidV1 - Trace1[i])/(Trace1[i-1] - Trace1[i]) for i in Afalling]
5889 
5890  CHAfreq = SAMPLErate / numpy.mean(numpy.diff(AIrising))
5891  CHAperiod = (numpy.mean(numpy.diff(AIrising)) * 1000.0) / SAMPLErate # time in mSec
5892 # Catch zero length array?
5893  try:
5894  Dummy_read = Arising[0]
5895  except:
5896  return
5897  if len(Arising) > 0 or len(Afalling) > 0:
5898  if Arising[0] > 0:
5899  try:
5900  anr1 = AIrising[0]
5901  except:
5902  anr1 = 0
5903  try:
5904  anr2 = AIrising[1]
5905  except:
5906  anr2 = SHOWsamples
5907  try:
5908  if AIfalling[0] < AIrising[0]:
5909  anf1 = AIfalling[1]
5910  else:
5911  anf1 = AIfalling[0]
5912  except:
5913  anf1 = 1
5914  else:
5915  try:
5916  anr1 = AIrising[1]
5917  except:
5918  anr1 = 0
5919  try:
5920  anr2 = AIrising[2]
5921  except:
5922  anr2 = SHOWsamples
5923  try:
5924  if AIfalling[1] < AIrising[1]:
5925  anf1 = AIfalling[2]
5926  else:
5927  anf1 = AIfalling[1]
5928  except:
5929  anf1 = 1
5930 # search Trace 2
5931 
5938  Brising = [i for (i, val) in enumerate(Trace2) if val >= MidV2 and Trace2[i-1] < MidV2]
5939  Bfalling = [i for (i, val) in enumerate(Trace2) if val <= MidV2 and Trace2[i-1] > MidV2]
5940  BIrising = [i - (Trace2[i] - MidV2)/(Trace2[i] - Trace2[i-1]) for i in Brising]
5941  BIfalling = [i - (MidV2 - Trace2[i])/(Trace2[i-1] - Trace2[i]) for i in Bfalling]
5942 
5943  CHBfreq = SAMPLErate / numpy.mean(numpy.diff(BIrising))
5944  CHBperiod = (numpy.mean(numpy.diff(BIrising)) * 1000.0) / SAMPLErate # time in mSec
5945 # Catch zero length array?
5946  try:
5947  Dummy_read = Brising[0]
5948  except:
5949  return
5950  if len(Brising) > 0 or len(Bfalling) > 0:
5951  if Brising[0] > 0:
5952  try:
5953  bnr1 = BIrising[0]
5954  except:
5955  bnr1 = 0
5956  try:
5957  bnr2 = BIrising[1]
5958  except:
5959  bnr2 = SHOWsamples
5960  try:
5961  if BIfalling[0] < BIrising[0]:
5962  bnf1 = BIfalling[1]
5963  else:
5964  bnf1 = BIfalling[0]
5965  except:
5966  bnf1 = 1
5967  else:
5968  try:
5969  bnr1 = BIrising[1]
5970  except:
5971  bnr1 = 0
5972  try:
5973  bnr2 = BIrising[2]
5974  except:
5975  bnr2 = SHOWsamples
5976  try:
5977  if BIfalling[1] < BIrising[1]:
5978  bnf1 = BIfalling[2]
5979  else:
5980  bnf1 = BIfalling[1]
5981  except:
5982  bnf1 = 1
5983  #
5984  CHAHW = float(((anf1 - anr1) * 1000.0) / SAMPLErate)
5985  CHALW = float(((anr2 - anf1) * 1000.0) / SAMPLErate)
5986  CHADCy = float(anf1 - anr1) / float(anr2 - anr1) * 100.0 # in percent
5987  CHBHW = float(((bnf1 - bnr1) * 1000.0) / SAMPLErate)
5988  CHBLW = float(((bnr2 - bnf1) * 1000.0) / SAMPLErate)
5989  CHBDCy = float(bnf1 - bnr1) / float(bnr2 - bnr1) * 100.0 # in percent
5990 #
5991  if bnr1 > anr1:
5992  CHBADelayR1 = float((bnr1 - anr1) * 1000.0 / SAMPLErate)
5993  else:
5994  CHBADelayR1 = float((bnr2 - anr1) * 1000.0 / SAMPLErate)
5995  CHBADelayR2 = float((bnr2 - anr2) * 1000.0 / SAMPLErate)
5996  CHBADelayF = float((bnf1 - anf1) * 1000.0 / SAMPLErate)
5997  try:
5998  CHABphase = 360.0*(float((bnr1 - anr1) * 1000.0 / SAMPLErate))/CHAperiod
5999  except:
6000  CHABphase = 0.0
6001  if CHABphase < 0.0:
6002  CHABphase = CHABphase + 360.0
6003 
6004 def ReInterploateTrigger(TrgBuff):
6005  global DX, TRIGGERsample, TRIGGERlevel
6006 
6007  DX = 0
6008  n = TRIGGERsample
6009  DY = TrgBuff[int(n)] - TrgBuff[int(n+1)]
6010  if DY != 0.0:
6011  DX = (TRIGGERlevel - TrgBuff[int(n+1)])/DY # calculate interpolated trigger point
6012  else:
6013  DX = 0
6014 
6015 def FindTriggerSample(TrgBuff): # find trigger time sample point of passed waveform array
6016  global AutoLevel, TgInput, TRIGGERlevel, TRIGGERentry, DX, SAMPLErate, Is_Triggered
6017  global HoldOffentry, HozPossentry, TRIGGERsample, TRACEsize, HozPoss, hozpos
6018  global Trigger_LPF_length, LPFTrigger
6019 
6020  # Set the TRACEsize variable
6021  TRACEsize = SHOWsamples # Set the trace length
6022  DX = 0
6023  Is_Triggered = 0
6024  if LPFTrigger.get() > 0:
6025  TFiltCoef = [] # empty coef array
6026  for n in range(Trigger_LPF_length.get()):
6027  TFiltCoef.append(float(1.0/Trigger_LPF_length.get()))
6028  TFiltCoef = numpy.array(TFiltCoef)
6029  TrgBuff = numpy.convolve(TrgBuff, TFiltCoef)
6030 
6031  if len(TrgBuff) == 0:
6032  return
6033  try:
6034  TrgMin = numpy.amin(TrgBuff)
6035  except:
6036  TrgMin = 0.0
6037  try:
6038  TrgMax = numpy.amax(TrgBuff)
6039  except:
6040  TrgMax = 0.0
6041 # Find trigger sample
6042  try:
6043  if AutoLevel.get() == 1:
6044  TRIGGERlevel = (TrgMin + TrgMax)/2
6045  TRIGGERentry.delete(0,"end")
6046  TRIGGERentry.insert(0, ' {0:.4f} '.format(TRIGGERlevel))
6047  else:
6048  TRIGGERlevel = eval(TRIGGERentry.get())
6049  except:
6050  TRIGGERentry.delete(0,END)
6051  TRIGGERentry.insert(0, TRIGGERlevel)
6052 # Start from first sample after HoldOff
6053  try:
6054  HoldOff = float(eval(HoldOffentry.get()))
6055  if HoldOff < 0:
6056  HoldOff = 0
6057  HoldOffentry.delete(0,END)
6058  HoldOffentry.insert(0, HoldOff)
6059  except:
6060  HoldOffentry.delete(0,END)
6061  HoldOffentry.insert(0, HoldOff)
6062 # slide trace left right by HozPoss
6063  try:
6064  HozPoss = float(eval(HozPossentry.get()))
6065  except:
6066  HozPossentry.delete(0,END)
6067  HozPossentry.insert(0, HozPoss)
6068 
6069  hldn = int(HoldOff * SAMPLErate/1000)
6070  hozpos = int(HozPoss * SAMPLErate/1000)
6071  if hozpos >= 0:
6072  TRIGGERsample = hldn
6073  else:
6074  TRIGGERsample = abs(hozpos)
6075 #
6076  Nmax = int(TRACEsize / 1.5) # first 2/3 of data set
6077  DX = 0
6078  n = TRIGGERsample
6079  TRIGGERlevel2 = 0.99 * TRIGGERlevel # Hysteresis to avoid triggering on noise
6080  if TRIGGERlevel2 < TrgMin:
6081  TRIGGERlevel2 = TrgMin
6082  if TRIGGERlevel2 > TrgMax:
6083  TRIGGERlevel2 = TrgMax
6084  ChInput = TrgBuff[int(n)]
6085  Prev = ChInput
6086  while ( ChInput >= TRIGGERlevel2) and n < Nmax:
6087  n = n + 1
6088  ChInput = TrgBuff[int(n)]
6089  while (ChInput <= TRIGGERlevel) and n < Nmax:
6090  Prev = ChInput
6091  n = n + 1
6092  ChInput = TrgBuff[int(n)]
6093  DY = ChInput - Prev
6094  if DY != 0.0:
6095  DX = (TRIGGERlevel - Prev)/DY # calculate interpolated trigger point
6096  else:
6097  DX = 0
6098  if TgEdge.get() == 1:
6099  TRIGGERlevel2 = 1.01 * TRIGGERlevel
6100  if TRIGGERlevel2 < TrgMin:
6101  TRIGGERlevel2 = TrgMin
6102  if TRIGGERlevel2 > TrgMax:
6103  TRIGGERlevel2 = TrgMax
6104  ChInput = TrgBuff[int(n)]
6105  Prev = ChInput
6106  while (ChInput <= TRIGGERlevel2) and n < Nmax:
6107  n = n + 1
6108  ChInput = TrgBuff[int(n)]
6109  while (ChInput >= TRIGGERlevel) and n < Nmax:
6110  Prev = ChInput
6111  n = n + 1
6112  ChInput = TrgBuff[int(n)]
6113  DY = Prev - ChInput
6114  try:
6115  DX = (Prev - TRIGGERlevel)/DY # calculate interpolated trigger point
6116  except:
6117  DX = 0
6118 
6119 # check to insure trigger point is in bounds
6120  if n < Nmax:
6121  TRIGGERsample = n - 1
6122  Is_Triggered = 1
6123  elif n > Nmax: # Didn't find edge in first 2/3 of data set
6124  TRIGGERsample = 1 + hldn # reset to begining
6125  Is_Triggered = 0
6126  if DX > 1:
6127  DX = 1 # never more than 100% of a sample period
6128  elif DX < 0:
6129  DX = 0 # never less than 0% of a sample period
6130  if math.isnan(DX):
6131  DX = 0
6132  TRIGGERsample = TRIGGERsample + hozpos
6133 
6134 def DestroyDigScreen():
6135  global win2, DigScreenStatus
6136 
6137  DigScreenStatus.set(0)
6138  win2.destroy()
6139 #
6140 def sel(): # change Digital I/O and update screen color readback
6141  global devx, DevID
6142  global D0, D1, D2, D3, D4, D5, D6, D7
6143  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
6144  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
6145  # sending 0x50 = set to 0, 0x51 = set to 1
6146  if D0.get() > 0:
6147  devx.ctrl_transfer( 0x40, D0.get(), PIO_0, 0, 0, 0, 100) # set PIO 0
6148  if D0.get() == 0x50:
6149  digin0.configure(text="Low", background="#00ff00")
6150  else:
6151  digin0.configure(text="Hi", background="#ff0000")
6152  else:
6153  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100)
6154  if Dval[0] == 0:
6155  digin0.configure(text="Low", background="#00ff00")
6156  else:
6157  digin0.configure(text="Hi", background="#ff0000")
6158  if D1.get() > 0:
6159  devx.ctrl_transfer( 0x40, D1.get(), PIO_1, 0, 0, 0, 100) # set PIO 1
6160  if D1.get() == 0x50:
6161  digin1.configure(text="Low", background="#00ff00")
6162  else:
6163  digin1.configure(text="Hi", background="#ff0000")
6164  else:
6165  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100)
6166  if Dval[0] == 0:
6167  digin1.configure(text="Low", background="#00ff00")
6168  else:
6169  digin1.configure(text="Hi", background="#ff0000")
6170  if D2.get() > 0:
6171  devx.ctrl_transfer( 0x40, D2.get(), PIO_2, 0, 0, 0, 100) # set PIO 2
6172  if D2.get() == 0x50:
6173  digin2.configure(text="Low", background="#00ff00")
6174  else:
6175  digin2.configure(text="Hi", background="#ff0000")
6176  else:
6177  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100)
6178  if Dval[0] == 0:
6179  digin2.configure(text="Low", background="#00ff00")
6180  else:
6181  digin2.configure(text="Hi", background="#ff0000")
6182  if D3.get() > 0:
6183  devx.ctrl_transfer( 0x40, D3.get(), PIO_3, 0, 0, 0, 100) # set PIO 3
6184  if D3.get() == 0x50:
6185  digin3.configure(text="Low", background="#00ff00")
6186  else:
6187  digin3.configure(text="Hi", background="#ff0000")
6188  else:
6189  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100)
6190  if Dval[0] == 0:
6191  digin3.configure(text="Low", background="#00ff00")
6192  else:
6193  digin3.configure(text="Hi", background="#ff0000")
6194  if D4.get() > 0:
6195  devx.ctrl_transfer( 0x40, D4.get(), PIO_4, 0, 0, 0, 100) # set PIO 4
6196  if D4.get() == 0x50:
6197  digin4.configure(text="Low", background="#00ff00")
6198  else:
6199  digin4.configure(text="Hi", background="#ff0000")
6200  else:
6201  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
6202  if Dval[0] == 0:
6203  digin4.configure(text="Low", background="#00ff00")
6204  else:
6205  digin4.configure(text="Hi", background="#ff0000")
6206  if D5.get() > 0:
6207  devx.ctrl_transfer( 0x40, D5.get(), PIO_5, 0, 0, 0, 100) # set PIO 5
6208  if D5.get() == 0x50:
6209  digin5.configure(text="Low", background="#00ff00")
6210  else:
6211  digin5.configure(text="Hi", background="#ff0000")
6212  else:
6213  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
6214  if Dval[0] == 0:
6215  digin5.configure(text="Low", background="#00ff00")
6216  else:
6217  digin5.configure(text="Hi", background="#ff0000")
6218  if D6.get() > 0:
6219  devx.ctrl_transfer( 0x40, D6.get(), PIO_6, 0, 0, 0, 100) # set PIO 6
6220  if D6.get() == 0x50:
6221  digin6.configure(text="Low", background="#00ff00")
6222  else:
6223  digin6.configure(text="Hi", background="#ff0000")
6224  else:
6225  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100)
6226  if Dval[0] == 0:
6227  digin6.configure(text="Low", background="#00ff00")
6228  else:
6229  digin6.configure(text="Hi", background="#ff0000")
6230  if D7.get() > 0:
6231  devx.ctrl_transfer( 0x40, D7.get(), PIO_7, 0, 0, 0, 100) # set PIO 7
6232  if D7.get() == 0x50:
6233  digin7.configure(text="Low", background="#00ff00")
6234  else:
6235  digin7.configure(text="Hi", background="#ff0000")
6236  else:
6237  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100)
6238  if Dval[0] == 0:
6239  digin7.configure(text="Low", background="#00ff00")
6240  else:
6241  digin7.configure(text="Hi", background="#ff0000")
6242 
6243 
6244 def MakeDigScreen():
6245  global D0, D1, D2, D3, D4, D5, D6, D7
6246  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
6247  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
6248  global DigScreenStatus, DacScreenStatus, win2, MuxScreenStatus
6249  # setup Dig output window
6250  if DigScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
6251  DigScreenStatus.set(1)
6252  win2 = Toplevel()
6253  win2.title("Dig Out")
6254  win2.resizable(FALSE,FALSE)
6255  win2.protocol("WM_DELETE_WINDOW", DestroyDigScreen)
6256  drb1 = Radiobutton(win2, text="D0-0", variable=D0, value=0x50, command=sel )
6257  drb1.grid(row=2, column=0, sticky=W)
6258  drb0z = Radiobutton(win2, text="D0-Z", variable=D0, value=0, command=sel )
6259  drb0z.grid(row=2, column=1, sticky=W)
6260  drb2 = Radiobutton(win2, text="D0-1", variable=D0, value=0x51, command=sel )
6261  drb2.grid(row=2, column=2, sticky=W)
6262  digin0 = Label(win2, text="Low", background = "#00ff00")
6263  digin0.grid(row=2, column=3, sticky=W)
6264  drb3 = Radiobutton(win2, text="D1-0", variable=D1, value=0x50, command=sel )
6265  drb3.grid(row=3, column=0, sticky=W)
6266  drb3z = Radiobutton(win2, text="D1-Z", variable=D1, value=0, command=sel )
6267  drb3z.grid(row=3, column=1, sticky=W)
6268  drb4 = Radiobutton(win2, text="D1-1", variable=D1, value=0x51, command=sel )
6269  drb4.grid(row=3, column=2, sticky=W)
6270  digin1 = Label(win2, text="Low", background = "#00ff00")
6271  digin1.grid(row=3, column=3, sticky=W)
6272  drb5 = Radiobutton(win2, text="D2-0", variable=D2, value=0x50, command=sel )
6273  drb5.grid(row=4, column=0, sticky=W)
6274  drb5z = Radiobutton(win2, text="D2-Z", variable=D2, value=0, command=sel )
6275  drb5z.grid(row=4, column=1, sticky=W)
6276  drb6 = Radiobutton(win2, text="D2-1", variable=D2, value=0x51, command=sel )
6277  drb6.grid(row=4, column=2, sticky=W)
6278  digin2 = Label(win2, text="Low", background = "#00ff00")
6279  digin2.grid(row=4, column=3, sticky=W)
6280  drb7 = Radiobutton(win2, text="D3-0", variable=D3, value=0x50, command=sel )
6281  drb7.grid(row=5, column=0, sticky=W)
6282  drb7z = Radiobutton(win2, text="D3-Z", variable=D3, value=0, command=sel )
6283  drb7z.grid(row=5, column=1, sticky=W)
6284  drb8 = Radiobutton(win2, text="D3-1", variable=D3, value=0x51, command=sel )
6285  drb8.grid(row=5, column=2, sticky=W)
6286  digin3 = Label(win2, text="Low", background = "#00ff00")
6287  digin3.grid(row=5, column=3, sticky=W)
6288  drb9 = Radiobutton(win2, text="D4-0", variable=D4, value=0x50, command=sel )
6289  drb9.grid(row=6, column=0, sticky=W)
6290  drb9z = Radiobutton(win2, text="D4-Z", variable=D4, value=0, command=sel )
6291  drb9z.grid(row=6, column=1, sticky=W)
6292  drb10 = Radiobutton(win2, text="D4-1", variable=D4, value=0x51, command=sel )
6293  drb10.grid(row=6, column=2, sticky=W)
6294  digin4 = Label(win2, text="Low", background = "#00ff00")
6295  digin4.grid(row=6, column=3, sticky=W)
6296  drb11 = Radiobutton(win2, text="D5-0", variable=D5, value=0x50, command=sel )
6297  drb11.grid(row=7, column=0, sticky=W)
6298  drb11z = Radiobutton(win2, text="D5-Z", variable=D5, value=0, command=sel )
6299  drb11z.grid(row=7, column=1, sticky=W)
6300  drb12 = Radiobutton(win2, text="D5-1", variable=D5, value=0x51, command=sel )
6301  drb12.grid(row=7, column=2, sticky=W)
6302  digin5 = Label(win2, text="Low", background = "#00ff00")
6303  digin5.grid(row=7, column=3, sticky=W)
6304  drb13 = Radiobutton(win2, text="D6-0", variable=D6, value=0x50, command=sel )
6305  drb13.grid(row=8, column=0, sticky=W)
6306  drb13z = Radiobutton(win2, text="D6-Z", variable=D6, value=0, command=sel )
6307  drb13z.grid(row=8, column=1, sticky=W)
6308  drb13 = Radiobutton(win2, text="D6-1", variable=D6, value=0x51, command=sel )
6309  drb13.grid(row=8, column=2, sticky=W)
6310  digin6 = Label(win2, text="Low", background = "#00ff00")
6311  digin6.grid(row=8, column=3, sticky=W)
6312  drb14 = Radiobutton(win2, text="D7-0", variable=D7, value=0x50, command=sel )
6313  drb14.grid(row=9, column=0, sticky=W)
6314  drb14z = Radiobutton(win2, text="D7-Z", variable=D7, value=0, command=sel )
6315  drb14z.grid(row=9, column=1, sticky=W)
6316  drb15 = Radiobutton(win2, text="D7-1", variable=D7, value=0x51, command=sel )
6317  drb15.grid(row=9, column=2, sticky=W)
6318  digin7 = Label(win2, text="Low", background = "#00ff00")
6319  digin7.grid(row=9, column=3, sticky=W)
6320 
6321  digdismissbutton = Button(win2, text="Dismiss", command=DestroyDigScreen)
6322  digdismissbutton.grid(row=10, column=0, sticky=W)
6323 
6324 def DestroyDacScreen():
6325  global win1, DacScreenStatus
6326 
6327  DacScreenStatus.set(0)
6328  win1.destroy()
6329 
6330 def sel0(temp):
6331  global devx, DevID
6332  global PIO_0, PIO_4
6333  global DAC0
6334  # sending 0x50 = set to 0, 0x51 = set to 1
6335  if DAC0.get() == 1:
6336  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
6337  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4 0
6338  elif DAC0.get() == 4:
6339  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
6340  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
6341  elif DAC0.get() == 2:
6342  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
6343  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
6344  elif DAC0.get() == 3:
6345  Dval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO 0 Z
6346  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
6347  elif DAC0.get() == 5:
6348  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
6349  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
6350  elif DAC0.get() == 7:
6351  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
6352  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
6353  elif DAC0.get() == 8:
6354  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 1
6355  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
6356  elif DAC0.get() == 6:
6357  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
6358  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
6359  elif DAC0.get() == 9:
6360  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
6361  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4
6362 
6363 def sel1(temp):
6364  global devx, DevID
6365  global PIO_1, PIO_5
6366  global DAC1
6367  # sending 0x50 = set to 0, 0x51 = set to 1
6368  if DAC1.get() == 1:
6369  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
6370  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4 0
6371  elif DAC1.get() == 4:
6372  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
6373  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
6374  elif DAC1.get() == 2:
6375  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
6376  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
6377  elif DAC1.get() == 3:
6378  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
6379  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
6380  elif DAC1.get() == 5:
6381  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
6382  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
6383  elif DAC1.get() == 7:
6384  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
6385  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
6386  elif DAC1.get() == 8:
6387  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0 1
6388  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
6389  elif DAC1.get() == 6:
6390  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
6391  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
6392  elif DAC1.get() == 9:
6393  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
6394  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4
6395 
6396 def sel2(temp):
6397  global devx, DevID
6398  global PIO_2, PIO_6
6399  global DAC2
6400  # sending 0x50 = set to 0, 0x51 = set to 1
6401  if DAC2.get() == 1:
6402  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
6403  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4 0
6404  elif DAC2.get() == 4:
6405  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
6406  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
6407  elif DAC2.get() == 2:
6408  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
6409  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
6410  elif DAC2.get() == 3:
6411  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
6412  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
6413  elif DAC2.get() == 5:
6414  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
6415  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
6416  elif DAC2.get() == 7:
6417  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
6418  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
6419  elif DAC2.get() == 8:
6420  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0 1
6421  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
6422  elif DAC2.get() == 6:
6423  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
6424  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
6425  elif DAC2.get() == 9:
6426  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
6427  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4
6428 
6429 def sel3(temp):
6430  global devx, DevID
6431  global PIO_3, PIO_7
6432  global DAC3
6433  # sending 0x50 = set to 0, 0x51 = set to 1
6434  if DAC3.get() == 1:
6435  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
6436  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4 0
6437  elif DAC3.get() == 4:
6438  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
6439  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
6440  elif DAC3.get() == 2:
6441  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
6442  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
6443  elif DAC3.get() == 3:
6444  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
6445  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
6446  elif DAC3.get() == 5:
6447  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
6448  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
6449  elif DAC3.get() == 7:
6450  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
6451  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
6452  elif DAC3.get() == 8:
6453  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0 1
6454  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
6455  elif DAC3.get() == 6:
6456  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
6457  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
6458  elif DAC3.get() == 9:
6459  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
6460  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4
6461 
6462 def MakeDacScreen():
6463  global DAC0, DAC1, DAC2, DAC3, SWRev, RevDate
6464  global DacScreenStatus, DigScreenStatus, win1, MuxScreenStatus
6465  # setup Dig output window
6466  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
6467  DacScreenStatus.set(1)
6468  win1 = Toplevel()
6469  win1.title("DAC Out "+ SWRev + RevDate)
6470  win1.resizable(FALSE,FALSE)
6471  win1.protocol("WM_DELETE_WINDOW", DestroyDacScreen)
6472  DAC0 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel0, length=90)
6473  DAC0.grid(row=0, column=0, sticky=W)
6474  DAC1 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel1, length=90)
6475  DAC1.grid(row=0, column=1, sticky=W)
6476  DAC2 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel2, length=90)
6477  DAC2.grid(row=0, column=2, sticky=W)
6478  DAC3 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel3, length=90)
6479  DAC3.grid(row=0, column=3, sticky=W)
6480 
6481  dismissbutton = Button(win1, text="Dismiss", command=DestroyDacScreen)
6482  dismissbutton.grid(row=1, column=0, columnspan=4, sticky=W)
6483 
6484 def UpdateTimeAll():
6485 
6486  MakeTimeTrace() # Update the traces
6487  UpdateTimeScreen() # Update the screen
6488 
6489 def UpdateTimeTrace():
6490 
6491  MakeTimeTrace() # Update traces
6492  UpdateTimeScreen() # Update the screen
6493 
6494 def UpdateTimeScreen():
6495 
6496  MakeTimeScreen() # Update the screen
6497  root.update() # Activate updated screens
6498 
6499 def UpdateXYAll():
6500 
6501  MakeXYTrace() # Update the traces
6502  UpdateXYScreen() # Update the screen
6503 
6504 def UpdateXYTrace():
6505 
6506  MakeXYTrace() # Update traces
6507  UpdateXYScreen() # Update the screen
6508 
6509 def UpdateXYScreen():
6510 
6511  MakeXYScreen() # Update the screen
6512  root.update() # Activate updated screens
6513 
6514 def MakeTimeTrace():
6515  global VBuffA, VBuffB, IBuffA, IBuffB
6516  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
6517  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
6518  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
6519  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
6520  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
6521  global D0line, D1line, D2line, D3line
6522  global FFTBuffA, FFTBuffB, FFTwindowshape
6523  global AWGAwaveform, AWGBwaveform
6524  global T1Vline, T2Vline, T1Iline, T2Iline
6525  global TMAVline, TMBVline, TMCVline, TMDVline
6526  global Tmathline, TMXline, TMYline
6527  global MathString, MathAxis, MathXString, MathYString, MathXAxis, MathYAxis
6528  global Triggerline, Triggersymbol, TgInput, TgEdge, HoldOff, HoldOffentry
6529  global X0L, Y0T, GRW, GRH, MouseX, MouseY, MouseCAV, MouseCAI, MouseCBV, MouseCBI
6530  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
6531  global SHOWsamples, ZOHold, AWGBMode
6532  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
6533  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
6534  global Show_MathX, Show_MathY
6535  global TRACES, TRACESread, RUNstatus
6536  global AutoCenterA, AutoCenterB
6537  global CHAsb, CHBsb, CHAOffset, CHBOffset, CHAIsb, CHBIsb, CHAIOffset, CHBIOffset
6538  global TMpdiv # Array with time / div values in ms
6539  global TMsb # Time per div spin box variable
6540  global TIMEdiv # current spin box value
6541  global SAMPLErate, SCstart, Two_X_Sample, DISsamples, First_Slow_sweep
6542  global TRIGGERsample, TRACEsize, DX, TRIGGERsampleAltA, TRIGGERsampleAltB
6543  global TRIGGERlevel, TRIGGERentry, AutoLevel
6544  global InOffA, InGainA, InOffB, InGainB
6545  global CurOffA, CurOffB, CurGainA, CurGainB
6546  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
6547  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
6548  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6549  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6550  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
6551  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
6552  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
6553  global HozPoss, HozPossentry
6554 
6555  # Set the TRACEsize variable
6556  if len(VBuffA) < 100 and MuxScreenStatus.get() == 0:
6557  return
6558  TRACEsize = SHOWsamples # Set the trace length
6559  SCstart = 0
6560  ylo = 0.0
6561  xlo = 0.0
6562  Ymin = Y0T # Minimum position of time grid (top)
6563  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
6564  Xmin = X0L # Minimum position of time grid (left)
6565  Xmax = X0L + GRW # Maximum position of time grid (right)
6566 
6567  # prevent divide by zero error
6568  if TIMEdiv < 0.0002:
6569  TIMEdiv = 0.01
6570  # Check for Auto Centering
6571  if AutoCenterA.get() > 0:
6572  CHAOffset = DCV1
6573  CHAVPosEntry.delete(0,END)
6574  CHAVPosEntry.insert(0, ' {0:.2f} '.format(CHAOffset))
6575  if AutoCenterB.get() > 0:
6576  CHBOffset = DCV2
6577  CHBVPosEntry.delete(0,END)
6578  CHBVPosEntry.insert(0, ' {0:.2f} '.format(CHBOffset))
6579  # get the vertical ranges
6580  try:
6581  CH1pdvRange = float(eval(CHAsb.get()))
6582  except:
6583  CHAsb.delete(0,END)
6584  CHAsb.insert(0, CH1pdvRange)
6585  try:
6586  CH2pdvRange = float(eval(CHBsb.get()))
6587  except:
6588  CHBsb.delete(0,END)
6589  CHBsb.insert(0, CH2pdvRange)
6590  try:
6591  CH1IpdvRange = float(eval(CHAIsb.get()))
6592  except:
6593  CHAIsb.delete(0,END)
6594  CHAIsb.insert(0, CH1IpdvRange)
6595  try:
6596  CH2IpdvRange = float(eval(CHBIsb.get()))
6597  except:
6598  CHBIsb.delete(0,END)
6599  CHBIsb.insert(0, CH2IpdvRange)
6600  # get the vertical offsets
6601  try:
6602  CHAOffset = float(eval(CHAVPosEntry.get()))
6603  except:
6604  CHAVPosEntry.delete(0,END)
6605  CHAVPosEntry.insert(0, CHAOffset)
6606  try:
6607  CHAIOffset = float(eval(CHAIPosEntry.get()))
6608  except:
6609  CHAIPosEntry.delete(0,END)
6610  CHAIPosEntry.insert(0, CHAIOffset)
6611  try:
6612  CHBOffset = float(eval(CHBVPosEntry.get()))
6613  except:
6614  CHBVPosEntry.delete(0,END)
6615  CHBVPosEntry.insert(0, CHBOffset)
6616  try:
6617  CHBIOffset = float(eval(CHBIPosEntry.get()))
6618  except:
6619  CHBIPosEntry.delete(0,END)
6620  CHBIPosEntry.insert(0, CHBIOffset)
6621  # prevent divide by zero error
6622  if CH1pdvRange < 0.001:
6623  CH1pdvRange = 0.001
6624  if CH2pdvRange < 0.001:
6625  CH2pdvRange = 0.001
6626  if CH1IpdvRange < 0.1:
6627  CH1IpdvRange = 0.1
6628  if CH2IpdvRange < 0.1:
6629  CH2IpdvRange = 0.1
6630 #
6631  try:
6632  HoldOff = float(eval(HoldOffentry.get()))
6633  if HoldOff < 0:
6634  HoldOff = 0
6635  HoldOffentry.delete(0,END)
6636  HoldOffentry.insert(0, HoldOff)
6637  except:
6638  HoldOffentry.delete(0,END)
6639  HoldOffentry.insert(0, HoldOff)
6640 #
6641  try:
6642  HozPoss = float(eval(HozPossentry.get()))
6643  except:
6644  HozPossentry.delete(0,END)
6645  HozPossentry.insert(0, HozPoss)
6646 #
6647  hldn = int(HoldOff * SAMPLErate/1000 )
6648  hozpos = int(HozPoss * SAMPLErate/1000 )
6649  if hozpos < 0:
6650  hozpos = 0
6651  # drawing the traces
6652  if TRACEsize == 0: # If no trace, skip rest of this routine
6653  T1Vline = [] # Trace line channel A V
6654  T2Vline = [] # Trace line channel B V
6655  T1Iline = []
6656  T2Iline = []
6657  TMAVline = [] # V Trace line Mux channel A
6658  TMBVline = [] # V Trace line Mux channel B
6659  TMCVline = [] # V Trace line Mux channel C
6660  TMDVline = [] # V Trace line Mux channel D
6661  Tmathline = [] # math trce line
6662  return()
6663 
6664  # set and/or corrected for in range
6665  if TgInput.get() > 0 or ChopTrig.get() > 0:
6666  SCmin = int(-1 * TRIGGERsample)
6667  SCmax = int(TRACEsize - TRIGGERsample - 0)
6668  else:
6669  SCmin = 0 # hldn
6670  SCmax = TRACEsize - 1
6671  if SCstart < SCmin: # No reading before start of array
6672  SCstart = SCmin
6673  if SCstart > SCmax: # No reading after end of array
6674  SCstart = SCmax
6675 
6676  # Make Trace lines etc.
6677 
6678  Yconv1 = float(GRH/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
6679  Yconv2 = float(GRH/10.0) / CH2pdvRange
6680  YIconv1 = float(GRH/10.0) / CH1IpdvRange
6681  YIconv2 = float(GRH/10.0) / CH2IpdvRange
6682  Xconv1 = float(GRW/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
6683  Xconv2 = float(GRW/10.0) / CH2pdvRange
6684  XIconv1 = float(GRW/10.0) / CH1IpdvRange
6685  XIconv2 = float(GRW/10.0) / CH2IpdvRange
6686  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
6687  try:
6688  CHMApdvRange = float(eval(CHB_Asb.get()))
6689  except:
6690  CHB_Asb.delete(0,END)
6691  CHB_Asb.insert(0, CHMApdvRange)
6692  try:
6693  CHMBpdvRange = float(eval(CHB_Bsb.get()))
6694  except:
6695  CHB_Bsb.delete(0,END)
6696  CHB_Bsb.insert(0, CHMBpdvRange)
6697  try:
6698  CHMCpdvRange = float(eval(CHB_Csb.get()))
6699  except:
6700  CHB_Csb.delete(0,END)
6701  CHB_Csb.insert(0, CHMCpdvRange)
6702  try:
6703  CHMDpdvRange = float(eval(CHB_Dsb.get()))
6704  except:
6705  CHB_Dsb.delete(0,END)
6706  CHB_Dsb.insert(0, CHMDpdvRange)
6707  YconvMA = float(GRH/10.0) / CHMApdvRange
6708  YconvMB = float(GRH/10.0) / CHMBpdvRange
6709  YconvMC = float(GRH/10.0) / CHMCpdvRange
6710  YconvMD = float(GRH/10.0) / CHMDpdvRange
6711  try:
6712  CHBAOffset = float(eval(CHB_APosEntry.get()))
6713  except:
6714  CHB_APosEntry.delete(0,END)
6715  CHB_APosEntry.insert(0, CHBAOffset)
6716  try:
6717  CHBBOffset = float(eval(CHB_BPosEntry.get()))
6718  except:
6719  CHB_BPosEntry.delete(0,END)
6720  CHB_BPosEntry.insert(0, CHBBOffset)
6721  try:
6722  CHBCOffset = float(eval(CHB_CPosEntry.get()))
6723  except:
6724  CHB_CPosEntry.delete(0,END)
6725  CHB_CPosEntry.insert(0, CHBCOffset)
6726  try:
6727  CHBDOffset = float(eval(CHB_DPosEntry.get()))
6728  except:
6729  CHB_DPosEntry.delete(0,END)
6730  CHB_DPosEntry.insert(0, CHBDOffset)
6731  if MathAxis == "V-A":
6732  YconvM = Yconv1
6733  CHMOffset = CHAOffset
6734  elif MathAxis == "V-B":
6735  YconvM = Yconv2
6736  CHMOffset = CHBOffset
6737  elif MathAxis == "I-A":
6738  YconvM = YIconv1
6739  CHMOffset = CHAIOffset
6740  elif MathAxis == "I-B":
6741  YconvM = YIconv2
6742  CHMOffset = CHBIOffset
6743  else:
6744  YconvM = Yconv1
6745  CHMOffset = CHAOffset
6746 # include ploting X and Y math formulas vs time
6747  if MathYAxis == "V-A":
6748  YconvMxy = Yconv1
6749  CHMYOffset = CHAOffset
6750  elif MathYAxis == "V-B":
6751  YconvMxy = Yconv2
6752  CHMYOffset = CHBOffset
6753  elif MathYAxis == "I-A":
6754  YconvMxy = YIconv1
6755  CHMYOffset = CHAIOffset
6756  elif MathYAxis == "I-B":
6757  YconvMxy = YIconv2
6758  CHMYOffset = CHBIOffset
6759  else:
6760  YconvMxy = Yconv1
6761  CHMYOffset = CHAOffset
6762 #
6763  if MathXAxis == "V-A":
6764  XconvMxy = Yconv1
6765  CHMXOffset = CHAOffset
6766  elif MathXAxis == "V-B":
6767  XconvMxy = Yconv2
6768  CHMXOffset = CHBOffset
6769  elif MathXAxis == "I-A":
6770  XconvMxy = YIconv1
6771  CHMXOffset = CHAIOffset
6772  elif MathXAxis == "I-B":
6773  XconvMxy = YIconv2
6774  CHMXOffset = CHBIOffset
6775  else:
6776  XconvMxy = Yconv1
6777  CHMXOffset = CHAOffset
6778 #
6779  c1 = GRH / 2.0 + Y0T # fixed correction channel A
6780  c2 = GRH / 2.0 + Y0T # fixed correction channel B
6781 
6782  if First_Slow_sweep == 1:
6783  TRACEsize = len(VBuffA)
6784  DISsamples = GRW
6785  D0line = []
6786  D1line = []
6787  D2line = []
6788  D3line = []
6789  Dconv = float(GRH/10.0) # pixels per Div
6790  else:
6791  DISsamples = SAMPLErate * 10.0 * TIMEdiv / 1000.0 # number of samples to display
6792  T1Vline = [] # V Trace line channel A
6793  T2Vline = [] # V Trace line channel B
6794  T1Iline = [] # I Trace line channel A
6795  T2Iline = [] # I Trace line channel B
6796  TMAVline = [] # V Trace line Mux channel A
6797  TMBVline = [] # V Trace line Mux channel B
6798  TMCVline = [] # V Trace line Mux channel C
6799  TMDVline = [] # V Trace line Mux channel D
6800  Tmathline = [] # math trce line
6801  TMXline = [] # X math Trace line
6802  TMYline = [] # Y math Trace line
6803  if len(VBuffA) < 4 and len(VBuffB) < 4 and len(IBuffA) < 4 and len(IBuffB) < 4:
6804  return
6805  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
6806  if t < 0:
6807  t = 0
6808  x = 0 # Horizontal screen pixel
6809 #
6810  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6811  ypi1 = int(c1 - YIconv1 * (IBuffA[t] - CHAIOffset))
6812  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6813  ypi2 = int(c1 - YIconv2 * (IBuffB[t] - CHBIOffset))
6814  DvY1 = DvY2 = DiY1 = DiY2 = 0
6815 #
6816  if (DISsamples <= GRW):
6817  Xstep = GRW / DISsamples
6818  if AWGBMode.get() == 2 and Two_X_Sample.get() == 0:
6819  xa = int((Xstep/-2.5) - (Xstep*DX))
6820  else:
6821  xa = 0 - int(Xstep*DX) # adjust start pixel for interpolated trigger point
6822  x = 0 - int(Xstep*DX)
6823  Tstep = 1
6824  x1 = 0 # x position of trace line
6825  xa1 = 0
6826  y1 = 0.0 # y position of trace line
6827  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6828  ytemp = IBuffA[t]
6829  ypi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6830  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6831  if MuxScreenStatus.get() == 1:
6832  if len(VBuffMA) > 4:
6833  ypvma = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6834  if len(VBuffMB) > 4:
6835  ypvmb = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6836  if len(VBuffMC) > 4:
6837  ypvmc = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6838  if len(VBuffMD) > 4:
6839  ypvmd = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6840  ytemp = IBuffB[t]
6841  ypi2 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6842  ypm = ypmx = ypmy = GRH / 2.0 + Y0T
6843  if TgInput.get() == 0:
6844  Xlimit = GRW
6845  else:
6846  Xlimit = GRW+Xstep
6847  while x <= Xlimit:
6848  if t < TRACEsize:
6849  xa1 = xa + X0L
6850  x1 = x + X0L
6851  y1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6852  ytemp = IBuffA[t]
6853  yi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6854 
6855  if y1 < Ymin: # clip waveform if going off grid
6856  y1 = Ymin
6857  if y1 > Ymax:
6858  y1 = Ymax
6859  if yi1 < Ymin:
6860  yi1 = Ymin
6861  if yi1 > Ymax:
6862  yi1 = Ymax
6863  if ShowC1_V.get() == 1 :
6864  if ZOHold.get() == 1:
6865  T1Vline.append(int(xa1))
6866  T1Vline.append(int(ypv1))
6867  T1Vline.append(int(xa1))
6868  T1Vline.append(int(y1))
6869  else:
6870  T1Vline.append(int(xa1))
6871  T1Vline.append(int(y1))
6872  DvY1 = ypv1 - y1
6873  ypv1 = y1
6874  if ShowC1_I.get() == 1:
6875  if ZOHold.get() == 1:
6876  T1Iline.append(int(xa1))
6877  T1Iline.append(int(ypi1))
6878  T1Iline.append(int(xa1))
6879  T1Iline.append(int(yi1))
6880  else:
6881  T1Iline.append(int(xa1))
6882  T1Iline.append(int(yi1))
6883  DiY1 = ypi1 - yi1
6884  ypi1 = yi1
6885  if ShowC2_V.get() == 1:
6886  y1 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6887  if y1 < Ymin: # clip waveform if going off grid
6888  y1 = Ymin
6889  if y1 > Ymax:
6890  y1 = Ymax
6891  if ZOHold.get() == 1:
6892  T2Vline.append(int(x1))
6893  T2Vline.append(int(ypv2))
6894  T2Vline.append(int(x1))
6895  T2Vline.append(int(y1))
6896  else:
6897  T2Vline.append(int(x1))
6898  T2Vline.append(int(y1))
6899  DvY2 = ypv2 - y1
6900  ypv2 = y1
6901  if Show_CBA.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMA)>4:
6902  y1 = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6903  if y1 < Ymin: # clip waveform if going off grid
6904  y1 = Ymin
6905  if y1 > Ymax:
6906  y1 = Ymax
6907  if ZOHold.get() == 1:
6908  TMAVline.append(int(x1))
6909  TMAVline.append(int(ypvma))
6910  TMAVline.append(int(x1))
6911  TMAVline.append(int(y1))
6912  else:
6913  TMAVline.append(int(x1))
6914  TMAVline.append(int(y1))
6915  ypvma = y1
6916  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6917  Xfine = MouseX - X0L - x
6918  MouseMuxA = ypvma - (y1 - ypvma) * (Xfine/Xstep)
6919  if Show_CBB.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMB)>4:
6920  y1 = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6921  if y1 < Ymin: # clip waveform if going off grid
6922  y1 = Ymin
6923  if y1 > Ymax:
6924  y1 = Ymax
6925  if ZOHold.get() == 1:
6926  TMBVline.append(int(x1))
6927  TMBVline.append(int(ypvmb))
6928  TMBVline.append(int(x1))
6929  TMBVline.append(int(y1))
6930  else:
6931  TMBVline.append(int(x1))
6932  TMBVline.append(int(y1))
6933  ypvmb = y1
6934  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6935  Xfine = MouseX - X0L - x
6936  MouseMuxB = ypvmb - (y1 - ypvmb) * (Xfine/Xstep)
6937  if Show_CBC.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMC)>4:
6938  y1 = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6939  if y1 < Ymin: # clip waveform if going off grid
6940  y1 = Ymin
6941  if y1 > Ymax:
6942  y1 = Ymax
6943  if ZOHold.get() == 1:
6944  TMCVline.append(int(x1))
6945  TMCVline.append(int(ypvmc))
6946  TMCVline.append(int(x1))
6947  TMCVline.append(int(y1))
6948  else:
6949  TMCVline.append(int(x1))
6950  TMCVline.append(int(y1))
6951  ypvmc = y1
6952  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6953  Xfine = MouseX - X0L - x
6954  MouseMuxC = ypvmc - (y1 - ypvmc) * (Xfine/Xstep)
6955  if Show_CBD.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMD)>4:
6956  y1 = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6957  if y1 < Ymin: # clip waveform if going off grid
6958  y1 = Ymin
6959  if y1 > Ymax:
6960  y1 = Ymax
6961  if ZOHold.get() == 1:
6962  TMDVline.append(int(x1))
6963  TMDVline.append(int(ypvmd))
6964  TMDVline.append(int(x1))
6965  TMDVline.append(int(y1))
6966  else:
6967  TMDVline.append(int(x1))
6968  TMDVline.append(int(y1))
6969  ypvmd = y1
6970  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6971  Xfine = MouseX - X0L - x
6972  MouseMuxD = ypvmd - (y1 - ypvmd) * (Xfine/Xstep)
6973  if ShowC2_I.get() == 1:
6974  ytemp = IBuffB[t]
6975  yi1 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6976  if yi1 < Ymin:
6977  yi1 = Ymin
6978  if yi1 > Ymax:
6979  yi1 = Ymax
6980  if (ZOHold.get() == 1):
6981  T2Iline.append(int(x1))
6982  T2Iline.append(int(ypi2))
6983  T2Iline.append(int(x1))
6984  T2Iline.append(int(yi1))
6985  else:
6986  T2Iline.append(int(x1))
6987  T2Iline.append(int(yi1))
6988  DiY2 = ypi2 - yi1
6989  ypi2 = yi1
6990  if MathTrace.get() > 0:
6991  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
6992  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
6993 
6994  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
6995  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
6996 
6997  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
6998  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
6999 
7000  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
7001  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
7002  ytemp = YIconv1 * (Ypower - CHAIOffset)
7003  y1 = int(c1 - ytemp)
7004 
7005  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
7006  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
7007  ytemp = YIconv2 * (Ypower - CHBIOffset)
7008  y1 = int(c2 - ytemp)
7009 
7010  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
7011  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
7012  ytemp = YIconv1 * (Yohms - CHAIOffset)
7013  y1 = int(c1 - ytemp)
7014 
7015  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
7016  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
7017  ytemp = YIconv2 * (Yohms - CHBIOffset)
7018  y1 = int(c2 - ytemp)
7019 
7020  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
7021  Ydif = (IBuffA[t] - IBuffB[t])# in mA
7022  ytemp = YIconv1 * (Ydif - CHAIOffset)
7023  y1 = int(c2 - ytemp)
7024 
7025  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
7026  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
7027  ytemp = YIconv2 * (Ydif - CHBIOffset)
7028  y1 = int(c2 - ytemp)
7029 
7030  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
7031  try:
7032  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
7033  except:
7034  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
7035 
7036  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
7037  try:
7038  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
7039  except:
7040  Y1 = (IBuffB[t] / 0.000001)
7041  ytemp = YIconv2 * (Y1 - CHBIOffset)
7042  y1 = int(c2 - ytemp)
7043 
7044  elif MathTrace.get() == 12: # plot from equation string
7045  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
7046  try:
7047  MathResult = eval(MathString)
7048  MathResult = MathResult - CHMOffset
7049  y1 = int(c1 - YconvM * MathResult)
7050  except:
7051  RUNstatus.set(0)
7052  x = Xlimit + 1 # exit loop
7053 
7054  if y1 < Ymin: # clip waveform if going off grid
7055  y1 = Ymin
7056  if y1 > Ymax:
7057  y1 = Ymax
7058  if ZOHold.get() == 1: # connet the dots with stair step
7059  Tmathline.append(int(x1))
7060  Tmathline.append(int(ypm))
7061  Tmathline.append(int(x1))
7062  Tmathline.append(int(y1))
7063  else: # connet the dots with single line
7064  Tmathline.append(int(x1))
7065  Tmathline.append(int(y1))
7066  ypm = y1
7067  if Show_MathX.get() > 0:
7068  try:
7069  MathResult = eval(MathXString)
7070  MathResult = MathResult - CHMXOffset
7071  y1 = int(c1 - XconvMxy * MathResult)
7072  except:
7073  RUNstatus.set(0)
7074  x = Xlimit + 1 # exit loop
7075 
7076  if y1 < Ymin: # clip waveform if going off grid
7077  y1 = Ymin
7078  if y1 > Ymax:
7079  y1 = Ymax
7080  if ZOHold.get() == 1: # connet the dots with stair step
7081  TMXline.append(int(x1))
7082  TMXline.append(int(ypmx))
7083  TMXline.append(int(x1))
7084  TMXline.append(int(y1))
7085  else: # connet the dots with single line
7086  TMXline.append(int(x1))
7087  TMXline.append(int(y1))
7088  ypmx = y1
7089  if Show_MathY.get() > 0:
7090  try:
7091  MathResult = eval(MathYString)
7092  MathResult = MathResult - CHMYOffset
7093  y1 = int(c1 - YconvMxy * MathResult)
7094  except:
7095  RUNstatus.set(0)
7096  x = Xlimit + 1 # exit loop
7097 
7098  if y1 < Ymin: # clip waveform if going off grid
7099  y1 = Ymin
7100  if y1 > Ymax:
7101  y1 = Ymax
7102  if ZOHold.get() == 1: # connet the dots with stair step
7103  TMYline.append(int(x1))
7104  TMYline.append(int(ypmy))
7105  TMYline.append(int(x1))
7106  TMYline.append(int(y1))
7107  else: # connet the dots with single line
7108  TMYline.append(int(x1))
7109  TMYline.append(int(y1))
7110  ypmy = y1
7111  if D0.get() == 0:
7112  yd = int(c1 - (( DBuff0[t]*0.9 - 5 ) * Dconv))
7113  D0line.append(int(x1))
7114  D0line.append(yd)
7115  if D1.get() == 0:
7116  yd = int(c1 - (( DBuff1[t]*0.9 - 4 ) * Dconv))
7117  D1line.append(int(x1))
7118  D1line.append(yd)
7119  if D2.get() == 0:
7120  yd = int(c1 - (( DBuff2[t]*0.9 - 3 ) * Dconv))
7121  D2line.append(int(x1))
7122  D2line.append(yd)
7123  if D3.get() == 0:
7124  yd = int(c1 - (( DBuff3[t]*0.9 - 2 ) * Dconv))
7125  D3line.append(int(x1))
7126  D3line.append(yd)
7127 
7128  # remember trace verticle pixel at X mouse location
7129  if MouseX - X0L >= x and MouseX - X0L < (x + Xstep): # - Xstep
7130  Xfine = MouseX - X0L - x
7131  MouseCAV = ypv1 - (DvY1 * (Xfine/Xstep)) # interpolate along yaxis
7132  MouseCAI = ypi1 - (DiY1 * (Xfine/Xstep))
7133  MouseCBV = ypv2 - (DvY2 * (Xfine/Xstep))
7134  MouseCBI = ypi2 - (DiY2 * (Xfine/Xstep))
7135  t = int(t + Tstep)
7136  x = x + Xstep
7137  xa = xa + Xstep
7138 
7139  else: #if (DISsamples > GRW): # if the number of samples is larger than the grid width need to ship over samples
7140  Xstep = 1
7141  Tstep = DISsamples / GRW # number of samples to skip per grid pixel
7142  x1 = 0.0 # x position of trace line
7143  ylo = 0.0 # ymin position of trace 1 line
7144  yhi = 0.0 # ymax position of trace 1 line
7145 
7146  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
7147  if t > len(VBuffA)-1:
7148  t = 0
7149  if t < 0:
7150  t = 0
7151  x = 0 # Horizontal screen pixel
7152  ft = t # time point with fractions
7153  while (x <= GRW):
7154  if (t < TRACEsize):
7155  if (t >= len(VBuffA)):
7156  t = len(VBuffA)-2
7157  x = GRW
7158  x1 = x + X0L
7159  ylo = VBuffA[t] - CHAOffset
7160  ilo = IBuffA[t] - CHAIOffset
7161  yhi = ylo
7162  ihi = ilo
7163  n = t
7164  while n < (t + Tstep) and n < TRACEsize:
7165  if ( ShowC1_V.get() == 1 ):
7166  v = VBuffA[t] - CHAOffset
7167  if v < ylo:
7168  ylo = v
7169  if v > yhi:
7170  yhi = v
7171  if ( ShowC1_I.get() == 1 ):
7172  i = IBuffA[t] - CHAIOffset
7173  if i < ilo:
7174  ilo = i
7175  if i > ihi:
7176  ihi = i
7177  n = n + 1
7178  if ( ShowC1_V.get() == 1 ):
7179  ylo = int(c1 - Yconv1 * ylo)
7180  yhi = int(c1 - Yconv1 * yhi)
7181  if (ylo < Ymin):
7182  ylo = Ymin
7183  if (ylo > Ymax):
7184  ylo = Ymax
7185  if (yhi < Ymin):
7186  yhi = Ymin
7187  if (yhi > Ymax):
7188  yhi = Ymax
7189  T1Vline.append(int(x1))
7190  T1Vline.append(int(ylo))
7191  T1Vline.append(int(x1))
7192  T1Vline.append(int(yhi))
7193  ypv1 = ylo
7194  if ( ShowC1_I.get() == 1 ):
7195  ilo = int(c1 - YIconv1 * ilo)
7196  ihi = int(c1 - YIconv1 * ihi)
7197  if (ilo < Ymin):
7198  ilo = Ymin
7199  if (ilo > Ymax):
7200  ilo = Ymax
7201  if (ihi < Ymin):
7202  ihi = Ymin
7203  if (ihi > Ymax):
7204  ihi = Ymax
7205  T1Iline.append(int(x1))
7206  T1Iline.append(int(ilo))
7207  T1Iline.append(int(x1))
7208  T1Iline.append(int(ihi))
7209  ypi1 = ilo
7210  ylo = VBuffB[t] - CHBOffset
7211  ilo = IBuffB[t] - CHBIOffset
7212  yhi = ylo
7213  ihi = ilo
7214  n = t
7215  if MuxScreenStatus.get() == 0:
7216  while n < (t + Tstep) and n < TRACEsize:
7217  if ( ShowC2_V.get() == 1 ):
7218  v = VBuffB[t] - CHBOffset
7219  if v < ylo:
7220  ylo = v
7221  if v > yhi:
7222  yhi = v
7223  if ( ShowC2_I.get() == 1 ):
7224  i = IBuffB[t] - CHBIOffset
7225  if i < ilo:
7226  ilo = i
7227  if i > ihi:
7228  ihi = i
7229  n = n + 1
7230  if ( ShowC2_V.get() == 1 ):
7231  ylo = int(c2 - Yconv2 * ylo)
7232  yhi = int(c2 - Yconv2 * yhi)
7233  if (ylo < Ymin):
7234  ylo = Ymin
7235  if (ylo > Ymax):
7236  ylo = Ymax
7237 
7238  if (yhi < Ymin):
7239  yhi = Ymin
7240  if (yhi > Ymax):
7241  yhi = Ymax
7242  T2Vline.append(int(x1))
7243  T2Vline.append(int(ylo))
7244  T2Vline.append(int(x1))
7245  T2Vline.append(int(yhi))
7246  ypv2 = ylo
7247  if ( ShowC2_I.get() == 1 ):
7248  ilo = int(c2 - YIconv2 * ilo)
7249  ihi = int(c2 - YIconv2 * ihi)
7250  if (ilo < Ymin):
7251  ilo = Ymin
7252  if (ilo > Ymax):
7253  ilo = Ymax
7254  if (ihi < Ymin):
7255  ihi = Ymin
7256  if (ihi > Ymax):
7257  ihi = Ymax
7258  T2Iline.append(int(x1))
7259  T2Iline.append(int(ilo))
7260  T2Iline.append(int(x1))
7261  T2Iline.append(int(ihi))
7262  ypi2 = ilo
7263  else:
7264  if Show_CBA.get() == 1 and len(VBuffMA)>4:
7265  if t < len(VBuffMA):
7266  ylo = VBuffMA[t] - CHBAOffset
7267  yhi = ylo
7268  n = t
7269  while n < (t + Tstep) and n < len(VBuffMA):
7270  v = VBuffMA[t] - CHBAOffset
7271  if v < ylo:
7272  ylo = v
7273  if v > yhi:
7274  yhi = v
7275  n = n + 1
7276  ylo = int(c2 - YconvMA * ylo)
7277  yhi = int(c2 - YconvMA * yhi)
7278  if (ylo < Ymin):
7279  ylo = Ymin
7280  if (ylo > Ymax):
7281  ylo = Ymax
7282  if (yhi < Ymin):
7283  yhi = Ymin
7284  if (yhi > Ymax):
7285  yhi = Ymax
7286  TMAVline.append(int(x1))
7287  TMAVline.append(int(ylo))
7288  TMAVline.append(int(x1))
7289  TMAVline.append(int(yhi))
7290  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
7291  MouseMuxA = ylo
7292  if Show_CBB.get() == 1 and len(VBuffMB)>4:
7293  if t < len(VBuffMB):
7294  ylo = VBuffMB[t] - CHBBOffset
7295  yhi = ylo
7296  n = t
7297  while n < (t + Tstep) and n < len(VBuffMB):
7298  v = VBuffMB[t] - CHBBOffset
7299  if v < ylo:
7300  ylo = v
7301  if v > yhi:
7302  yhi = v
7303  n = n + 1
7304  ylo = int(c2 - YconvMB * ylo)
7305  yhi = int(c2 - YconvMB * yhi)
7306  if (ylo < Ymin):
7307  ylo = Ymin
7308  if (ylo > Ymax):
7309  ylo = Ymax
7310  if (yhi < Ymin):
7311  yhi = Ymin
7312  if (yhi > Ymax):
7313  yhi = Ymax
7314  TMBVline.append(int(x1))
7315  TMBVline.append(int(ylo))
7316  TMBVline.append(int(x1))
7317  TMBVline.append(int(yhi))
7318  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
7319  MouseMuxB = ylo
7320  if Show_CBC.get() == 1 and len(VBuffMC)>4:
7321  if t < len(VBuffMC):
7322  ylo = VBuffMC[t] - CHBCOffset
7323  yhi = ylo
7324  n = t
7325  while n < (t + Tstep) and n < len(VBuffMC):
7326  v = VBuffMC[t] - CHBCOffset
7327  if v < ylo:
7328  ylo = v
7329  if v > yhi:
7330  yhi = v
7331  n = n + 1
7332  ylo = int(c2 - YconvMC * ylo)
7333  yhi = int(c2 - YconvMC * yhi)
7334  if (ylo < Ymin):
7335  ylo = Ymin
7336  if (ylo > Ymax):
7337  ylo = Ymax
7338  if (yhi < Ymin):
7339  yhi = Ymin
7340  if (yhi > Ymax):
7341  yhi = Ymax
7342  TMCVline.append(int(x1))
7343  TMCVline.append(int(ylo))
7344  TMCVline.append(int(x1))
7345  TMCVline.append(int(yhi))
7346  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
7347  MouseMuxC = ylo
7348  if Show_CBD.get() == 1 and len(VBuffMD)>4:
7349  if t < len(VBuffMD):
7350  ylo = VBuffMD[t] - CHBDOffset
7351  yhi = ylo
7352  n = t
7353  while n < (t + Tstep) and n < len(VBuffMD):
7354  v = VBuffMD[t] - CHBDOffset
7355  if v < ylo:
7356  ylo = v
7357  if v > yhi:
7358  yhi = v
7359  n = n + 1
7360  ylo = int(c2 - YconvMD * ylo)
7361  yhi = int(c2 - YconvMD * yhi)
7362  if (ylo < Ymin):
7363  ylo = Ymin
7364  if (ylo > Ymax):
7365  ylo = Ymax
7366  if (yhi < Ymin):
7367  yhi = Ymin
7368  if (yhi > Ymax):
7369  yhi = Ymax
7370  TMDVline.append(int(x1))
7371  TMDVline.append(int(ylo))
7372  TMDVline.append(int(x1))
7373  TMDVline.append(int(yhi))
7374  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
7375  MouseMuxD = ylo
7376  if ( ShowC2_I.get() == 1 ):
7377  while n < (t + Tstep) and n < TRACEsize:
7378  i = IBuffB[t] - CHBIOffset
7379  if i < ilo:
7380  ilo = i
7381  if i > ihi:
7382  ihi = i
7383  n = n + 1
7384  ilo = int(c2 - YIconv2 * ilo)
7385  ihi = int(c2 - YIconv2 * ihi)
7386  if (ilo < Ymin):
7387  ilo = Ymin
7388  if (ilo > Ymax):
7389  ilo = Ymax
7390  if (ihi < Ymin):
7391  ihi = Ymin
7392  if (ihi > Ymax):
7393  ihi = Ymax
7394  T2Iline.append(int(x1))
7395  T2Iline.append(int(ilo))
7396  T2Iline.append(int(x1))
7397  T2Iline.append(int(ihi))
7398  if MathTrace.get() > 0:
7399  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
7400  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
7401 
7402  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
7403  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
7404 
7405  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7406  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
7407 
7408  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
7409  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
7410  ytemp = YIconv1 * (Ypower - CHAIOffset)
7411  y1 = int(c1 - ytemp)
7412 
7413  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
7414  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
7415  ytemp = YIconv2 * (Ypower - CHBIOffset)
7416  y1 = int(c2 - ytemp)
7417 
7418  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
7419  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
7420  ytemp = YIconv1 * (Yohms- CHAIOffset)
7421  y1 = int(c1 - ytemp)
7422 
7423  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
7424  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
7425  ytemp = YIconv2 * (Yohms - CHBIOffset)
7426  y1 = int(c2 - ytemp)
7427 
7428  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
7429  Ydif = (IBuffA[t] - IBuffB[t]) # in mA
7430  ytemp = YIconv1 * (Ydif - CHAIOffset)
7431  y1 = int(c2 - ytemp)
7432 
7433  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
7434  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
7435  ytemp = YIconv2 * (Ydif - CHBIOffset)
7436  y1 = int(c2 - ytemp)
7437 
7438  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
7439  try:
7440  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
7441  except:
7442  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
7443  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
7444  try:
7445  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
7446  except:
7447  Y1 = (IBuffB[t] / 0.000001)
7448  ytemp = YIconv2 * (Y1 - CHBIOffset)
7449  y1 = int(c2 - ytemp)
7450 
7451  elif MathTrace.get() == 12: # plot from equation string
7452  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
7453  try:
7454  MathResult = eval(MathString)
7455  MathResult = MathResult - CHMOffset
7456  y1 = int(c1 - YconvM * MathResult)
7457  except:
7458  RUNstatus.set(0)
7459  x = GRW + 1
7460 
7461  if (y1 < Ymin):
7462  y1 = Ymin
7463  if (y1 > Ymax):
7464  y1 = Ymax
7465  if (ZOHold.get() == 1):
7466  Tmathline.append(int(x1))
7467  Tmathline.append(int(ypm))
7468  Tmathline.append(int(x1))
7469  Tmathline.append(int(y1))
7470  else:
7471  Tmathline.append(int(x1))
7472  Tmathline.append(int(y1))
7473  ypm = y1
7474  if Show_MathX.get() > 0:
7475  try:
7476  MathResult = eval(MathXString)
7477  MathResult = MathResult - CHMXOffset
7478  y1 = int(c1 - XconvMxy * MathResult)
7479  except:
7480  RUNstatus.set(0)
7481  x = GRW + 1
7482 
7483  if y1 < Ymin: # clip waveform if going off grid
7484  y1 = Ymin
7485  if y1 > Ymax:
7486  y1 = Ymax
7487  if ZOHold.get() == 1: # connet the dots with stair step
7488  TMXline.append(int(x1))
7489  TMXline.append(int(ypmx))
7490  TMXline.append(int(x1))
7491  TMXline.append(int(y1))
7492  else: # connet the dots with single line
7493  TMXline.append(int(x1))
7494  TMXline.append(int(y1))
7495  ypmx = y1
7496  if Show_MathY.get() > 0:
7497  try:
7498  MathResult = eval(MathYString)
7499  MathResult = MathResult - CHMYOffset
7500  y1 = int(c1 - YconvMxy * MathResult)
7501  except:
7502  RUNstatus.set(0)
7503  x = GRW + 1
7504 
7505  if y1 < Ymin: # clip waveform if going off grid
7506  y1 = Ymin
7507  if y1 > Ymax:
7508  y1 = Ymax
7509  if ZOHold.get() == 1: # connet the dots with stair step
7510  TMYline.append(int(x1))
7511  TMYline.append(int(ypmy))
7512  TMYline.append(int(x1))
7513  TMYline.append(int(y1))
7514  else: # connet the dots with single line
7515  TMYline.append(int(x1))
7516  TMYline.append(int(y1))
7517  ypmy = y1
7518  ft = ft + Tstep
7519  if (MouseX - X0L) == x: # > (x - 1) and (MouseX - X0L) < (x + 1):
7520  MouseCAV = ypv1
7521  MouseCAI = ypi1
7522  MouseCBV = ypv2
7523  MouseCBI = ypi2
7524  t = int(ft)
7525  if (t > len(VBuffA)):
7526  t = len(VBuffA)-2
7527  x = GRW
7528  x = x + Xstep
7529 
7530  # Make trigger triangle pointer
7531  Triggerline = [] # Trigger pointer
7532  Triggersymbol = [] # Trigger symbol
7533  if TgInput.get() > 0 or ChopTrig.get() > 0:
7534  if TgInput.get() == 1 or TgInput.get() == 5: # triggering on CA-V
7535  x1 = X0L
7536  ytemp = Yconv1 * (float(TRIGGERlevel)-CHAOffset) #
7537  y1 = int(c1 - ytemp)
7538  elif TgInput.get() == 2: # triggering on CA-I
7539  x1 = X0L+GRW
7540  y1 = int(c1 - YIconv1 * (float(TRIGGERlevel) - CHAIOffset))
7541  elif TgInput.get() == 3: # triggering on CB-V
7542  x1 = X0L
7543  ytemp = Yconv2 * (float(TRIGGERlevel)-CHBOffset) #
7544  y1 = int(c2 - ytemp)
7545  elif TgInput.get() == 4: # triggering on CB-I
7546  x1 = X0L+GRW
7547  y1 = int(c2 - YIconv2 * (float(TRIGGERlevel) - CHBIOffset))
7548  elif ChopTrig.get() == 1: # triggering on Mux A
7549  x1 = X0L
7550  ytemp = YconvMA * (float(TRIGGERlevel)-CHBAOffset) #
7551  y1 = int(c1 - ytemp)
7552  elif ChopTrig.get() == 2: # triggering on Mux B
7553  x1 = X0L
7554  ytemp = YconvMB * (float(TRIGGERlevel)-CHBBOffset) #
7555  y1 = int(c1 - ytemp)
7556  elif ChopTrig.get() == 3: # triggering on Mux A
7557  x1 = X0L
7558  ytemp = YconvMC * (float(TRIGGERlevel)-CHBCOffset) #
7559  y1 = int(c1 - ytemp)
7560  elif ChopTrig.get() == 4: # triggering on Mux A
7561  x1 = X0L
7562  ytemp = YconvMD * (float(TRIGGERlevel)-CHBDOffset) #
7563  y1 = int(c1 - ytemp)
7564  #
7565  if (y1 < Ymin):
7566  y1 = Ymin
7567  if (y1 > Ymax):
7568  y1 = Ymax
7569  Triggerline.append(int(x1-5))
7570  Triggerline.append(int(y1+5))
7571  Triggerline.append(int(x1+5))
7572  Triggerline.append(int(y1))
7573  Triggerline.append(int(x1-5))
7574  Triggerline.append(int(y1-5))
7575  Triggerline.append(int(x1-5))
7576  Triggerline.append(int(y1+5))
7577  x1 = X0L + (GRW/2)
7578  if TgEdge.get() == 0: # draw rising edge symbol
7579  y1 = -3
7580  y2 = -13
7581  else:
7582  y1 = -13
7583  y2 = -3
7584  Triggersymbol.append(int(x1-10))
7585  Triggersymbol.append(int(Ymin+y1))
7586  Triggersymbol.append(int(x1))
7587  Triggersymbol.append(int(Ymin+y1))
7588  Triggersymbol.append(int(x1))
7589  Triggersymbol.append(int(Ymin+y2))
7590  Triggersymbol.append(int(x1+10))
7591  Triggersymbol.append(int(Ymin+y2))
7592 
7593 def MakeXYTrace():
7594  global VBuffA, VBuffB, IBuffA, IBuffB
7595  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
7596  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
7597  global XYlineVA, XYlineVB, XYlineIA, XYlineIB, XYlineM, XYlineMX, XYlineMY
7598  global MathXString, MathYString, MathAxis, MathXAxis, MathYAxis
7599  global HoldOff, HoldOffentry
7600  global X0LXY, Y0TXY, GRWXY, GRHXY
7601  global YminXY, YmaxXY, XminXY, XmaxXY
7602  global SHOWsamples, ZOHold, AWGBMode
7603  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
7604  global TRACES, TRACESread, RUNstatus
7605  global Xsignal, YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
7606  global CHAsbxy, CHBsbxy, CHAOffset, CHBOffset, CHAIsbxy, CHBIsbxy, CHAIOffset, CHBIOffset
7607  global TMpdiv # Array with time / div values in ms
7608  global TMsb # Time per div spin box variable
7609  global TIMEdiv # current spin box value
7610  global SAMPLErate
7611  global SCstart, MathString
7612  global TRIGGERsample, TRACEsize, DX
7613  global TRIGGERlevel, TRIGGERentry, AutoLevel
7614  global InOffA, InGainA, InOffB, InGainB
7615  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
7616  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
7617  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7618  global CHAVPosEntryxy, CHAIPosEntryxy, CHAVPosEntryxy, CHBIPosEntryxy
7619  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
7620  global HozPoss, HozPossentry
7621 
7622  # Set the TRACEsize variable
7623  if len(VBuffA) < 100:
7624  return
7625  TRACEsize = SHOWsamples # Set the trace length
7626  SCstart = 0
7627  yloVA = yloVB = yloIA = yloIB = yloM = yloMX = yloMY = 0.0
7628  xlo = 0.0
7629  # get the vertical ranges
7630  try:
7631  CH1pdvRange = float(eval(CHAsbxy.get()))
7632  except:
7633  CHAsbxy.delete(0,END)
7634  CHAsbxy.insert(0, CH1pdvRange)
7635  try:
7636  CH2pdvRange = float(eval(CHBsbxy.get()))
7637  except:
7638  CHBsbxy.delete(0,END)
7639  CHBsbxy.insert(0, CH2pdvRange)
7640  try:
7641  CH1IpdvRange = float(eval(CHAIsbxy.get()))
7642  except:
7643  CHAIsbxy.delete(0,END)
7644  CHAIsbxy.insert(0, CH1IpdvRange)
7645  try:
7646  CH2IpdvRange = float(eval(CHBIsbxy.get()))
7647  except:
7648  CHBIsbxy.delete(0,END)
7649  CHBIsbxy.insert(0, CH2IpdvRange)
7650  # get the vertical offsets
7651  try:
7652  CHAOffset = float(eval(CHAVPosEntryxy.get()))
7653  except:
7654  CHAVPosEntryxy.delete(0,END)
7655  CHAVPosEntryxy.insert(0, CHAOffset)
7656  try:
7657  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
7658  except:
7659  CHAIPosEntryxy.delete(0,END)
7660  CHAIPosEntryxy.insert(0, CHAIOffset)
7661  try:
7662  CHBOffset = float(eval(CHBVPosEntryxy.get()))
7663  except:
7664  CHBVPosEntry.delete(0,END)
7665  CHBVPosEntry.insert(0, CHBOffset)
7666  try:
7667  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
7668  except:
7669  CHBIPosEntryxy.delete(0,END)
7670  CHBIPosEntryxy.insert(0, CHBIOffset)
7671  # prevent divide by zero error
7672  if CH1pdvRange < 0.001:
7673  CH1pdvRange = 0.001
7674  if CH2pdvRange < 0.001:
7675  CH2pdvRange = 0.001
7676  if CH1IpdvRange < 0.1:
7677  CH1IpdvRange = 0.1
7678  if CH2IpdvRange < 0.1:
7679  CH2IpdvRange = 0.1
7680  #
7681  Yconv1 = float(GRHXY/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
7682  Yconv2 = float(GRHXY/10.0) / CH2pdvRange
7683  YIconv1 = float(GRHXY/10.0) / CH1IpdvRange
7684  YIconv2 = float(GRHXY/10.0) / CH2IpdvRange
7685  Xconv1 = float(GRWXY/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
7686  Xconv2 = float(GRWXY/10.0) / CH2pdvRange
7687  XIconv1 = float(GRWXY/10.0) / CH1IpdvRange
7688  XIconv2 = float(GRWXY/10.0) / CH2IpdvRange
7689 
7690  if MathAxis == "V-A":
7691  YconvM = Yconv1
7692  CHMOffset = CHAOffset
7693  elif MathAxis == "V-B":
7694  YconvM = Yconv2
7695  CHMOffset = CHBOffset
7696  elif MathAxis == "I-A":
7697  YconvM = YIconv1
7698  CHMOffset = CHAIOffset
7699  elif MathAxis == "I-B":
7700  YconvM = YIconv2
7701  CHMOffset = CHBIOffset
7702  else:
7703  YconvM = Yconv1
7704  CHMYOffset = CHAOffset
7705  if MathYAxis == "V-A":
7706  YconvMy = Yconv1
7707  CHMYOffset = CHAOffset
7708  elif MathYAxis == "V-B":
7709  YconvMy = Yconv2
7710  CHMYOffset = CHBOffset
7711  elif MathYAxis == "I-A":
7712  YconvMy = YIconv1
7713  CHMYOffset = CHAIOffset
7714  elif MathYAxis == "I-B":
7715  YconvMy = YIconv2
7716  CHMYOffset = CHBIOffset
7717  else:
7718  YconvMy = Yconv1
7719  CHMYOffset = CHAOffset
7720  if MathXAxis == "V-A":
7721  XconvMxy = Xconv1
7722  CHMXOffset = CHAOffset
7723  YconvMx = Yconv1
7724  elif MathXAxis == "V-B":
7725  XconvMxy = Xconv2
7726  CHMXOffset = CHBOffset
7727  YconvMx = Yconv2
7728  elif MathXAxis == "I-A":
7729  XconvMxy = XIconv1
7730  CHMXOffset = CHAIOffset
7731  YconvMx = YIconv1
7732  elif MathXAxis == "I-B":
7733  XconvMxy = XIconv2
7734  CHMXOffset = CHBIOffset
7735  YconvMx = YIconv2
7736  else:
7737  XconvMxy = Xconv1
7738  CHMXOffset = CHAOffset
7739  YconvMx = Yconv1
7740  # draw an X/Y plot
7741  XYlineVA = [] # XY Trace lines
7742  XYlineVB = []
7743  XYlineIA = []
7744  XYlineIB = []
7745  XYlineM = []
7746  XYlineMX = []
7747  XYlineMY = []
7748  t = int(TRIGGERsample) # skip over sampled before hold off time and trigger point
7749  c1 = GRHXY / 2.0 + Y0TXY # fixed correction channel A
7750  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7751  while (t < TRACEsize):
7752  # calculate X axis points
7753  if Xsignal.get() == 1: # CVA
7754  xlo = VBuffA[t] - CHAOffset
7755  xlo = int(c2 + Xconv1 * xlo)
7756  elif Xsignal.get() == 3: # CVB
7757  xlo = VBuffB[t] - CHBOffset
7758  xlo = int(c2 + Xconv2 * xlo)
7759  elif Xsignal.get() == 2: # CAI
7760  xlo = (IBuffA[t]) - CHAIOffset
7761  xlo = int(c2 + XIconv1 * xlo)
7762  elif Xsignal.get() == 4: # CBI
7763  xlo = (IBuffB[t]) - CHBIOffset
7764  xlo = int(c2 + XIconv2 * xlo)
7765  elif Xsignal.get() == 5: # Math
7766  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7767  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
7768  xlo = int(c2 + Xconv1 * xlo)
7769  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7770  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
7771  xlo = int(c2 + Xconv2 * xlo)
7772  else:
7773  try:
7774  MathResult = eval(MathXString)
7775  MathResult = MathResult - CHMXOffset
7776  xlo = int(c2 + XconvMxy * MathResult)
7777  except:
7778  RUNstatus.set(0)
7779  if xlo < XminXY: # clip waveform if going off grid
7780  xlo = XminXY
7781  if xlo > XmaxXY:
7782  xlo = XmaxXY
7783  # calculate Y axis points
7784  if YsignalVA.get() == 1: # CAV
7785  yloVA = VBuffA[t] - CHAOffset
7786  yloVA = int(c1 - Yconv1 * yloVA)
7787  if yloVA < YminXY: # clip waveform if going off grid
7788  yloVA = YminXY
7789  if yloVA > YmaxXY:
7790  yloVA = YmaxXY
7791  XYlineVA.append(int(xlo))
7792  XYlineVA.append(int(yloVA))
7793  if YsignalVB.get() == 1: # CBV
7794  yloVB = VBuffB[t] - CHBOffset
7795  yloVB = int(c1 - Yconv2 * yloVB)
7796  if yloVB < YminXY: # clip waveform if going off grid
7797  yloVB = YminXY
7798  if yloVB > YmaxXY:
7799  yloVB = YmaxXY
7800  XYlineVB.append(int(xlo))
7801  XYlineVB.append(int(yloVB))
7802  if YsignalIB.get() == 1: # CBI
7803  yloIB = (IBuffB[t]) - CHBIOffset
7804  yloIB = int(c1 - YIconv2 * yloIB)
7805  if yloIB < YminXY: # clip waveform if going off grid
7806  yloIB = YminXY
7807  if yloIB > YmaxXY:
7808  yloIB = YmaxXY
7809  XYlineIB.append(int(xlo))
7810  XYlineIB.append(int(yloIB))
7811  if YsignalIA.get() == 1: # CAI
7812  yloIA = (IBuffA[t]) - CHAIOffset
7813  yloIA = int(c1 - YIconv1 * yloIA)
7814  if yloIA < YminXY: # clip waveform if going off grid
7815  yloIA = YminXY
7816  if yloIA > YmaxXY:
7817  yloIA = YmaxXY
7818  XYlineIA.append(int(xlo))
7819  XYlineIA.append(int(yloIA))
7820  if YsignalM.get() == 1: # Math
7821  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7822  yloM = VBuffA[t] - VBuffB[t] - CHAOffset
7823  yloM = int(c1 - Yconv1 * yloM)
7824  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7825  yloM = VBuffB[t] - VBuffA[t] - CHBOffset
7826  yloM = int(c1 - Yconv2 * yloM)
7827  else:
7828  try:
7829  MathResult = eval(MathString)
7830  MathResult = MathResult - CHMOffset
7831  yloM = int(c1 - YconvM * MathResult)
7832  except:
7833  RUNstatus.set(0)
7834  if yloM < YminXY: # clip waveform if going off grid
7835  yloM = YminXY
7836  if yloM > YmaxXY:
7837  yloM = YmaxXY
7838  XYlineM.append(int(xlo))
7839  XYlineM.append(int(yloM))
7840  if YsignalMX.get() == 1: # Math-X
7841  try:
7842  MathResult = eval(MathXString)
7843  MathResult = MathResult - CHMXOffset
7844  yloMX = int(c1 - YconvMx * MathResult)
7845  except:
7846  RUNstatus.set(0)
7847  if yloMX < YminXY: # clip waveform if going off grid
7848  yloMX = YminXY
7849  if yloMX > YmaxXY:
7850  yloMX = YmaxXY
7851  XYlineMX.append(int(xlo))
7852  XYlineMX.append(int(yloMX))
7853  if YsignalMY.get() == 1: # Math-Y
7854  try:
7855  MathResult = eval(MathYString)
7856  MathResult = MathResult - CHMYOffset
7857  yloMY = int(c1 - YconvMy * MathResult)
7858  except:
7859  RUNstatus.set(0)
7860  if yloMY < YminXY: # clip waveform if going off grid
7861  yloMY = YminXY
7862  if yloMY > YmaxXY:
7863  yloMY = YmaxXY
7864  XYlineMY.append(int(xlo))
7865  XYlineMY.append(int(yloMY))
7866 
7867  t = int(t + 1)
7868 
7869 def MakeTimeScreen():
7870  global T1Vline, T2Vline, T1Iline, T2Iline, TXYline # active trave lines
7871  global TMXline, TMYline
7872  global T1VRline, T2VRline, T1IRline, T2IRline # reference trace lines
7873  global D0line, D1line, D2line, D3line, D0, D1, D2, D3
7874  global Triggerline, Triggersymbol, Tmathline, TMRline, TXYRline
7875  global VBuffA, VBuffB, IBuffA, IBuffB
7876  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
7877  global TMAVline, TMBVline, TMCVline, TMDVline, TMARline, TMBRline, TMCRline, TMDRline
7878  global VmemoryA, VmemoryB, VmemoryA, ImemoryB
7879  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
7880  global X0L # Left top X value
7881  global Y0T # Left top Y value
7882  global GRW # Screenwidth
7883  global GRH # Screenheight
7884  global FontSize, EnableHSsampling, ETSDisp, MinigenScreenStatus
7885  global LabelPlotText, PlotLabelText # plot custom label text flag
7886  global MouseX, MouseY, MouseWidget, MouseCAV, MouseCAI, MouseCBV, MouseCBI
7887  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
7888  global ShowXCur, ShowYCur, TCursor, VCursor
7889  global SHOWsamples # Number of samples in data record
7890  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Show_MathX, Show_MathY
7891  global ShowRA_V, ShowRA_I, ShowRB_V, ShowRB_I, ShowMath
7892  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MathUnits, MathXUnits, MathYUnits
7893  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
7894  global Xsignal, Ysignal, MathTrace, MathAxis, MathXAxis, MathYAxis
7895  global RUNstatus, SingleShot, ManualTrigger, session # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
7896  global CHAsb # V range spinbox Index for channel 1
7897  global CHBsb # V range spinbox Index for channel 2
7898  global CHAOffset # Position value for channel 1 V
7899  global CHBOffset # Position value for channel 2 V
7900  global CHAIsb # I range spinbox Index for channel 1
7901  global CHBIsb # I range spinbox Index for channel 2
7902  global CHAIOffset # Postion value for channel 1 I
7903  global CHBIOffset # position value for channel 2 I
7904  global TMpdiv # Array with time / div values in ms
7905  global TMsb # Time per div spin box variable
7906  global TIMEdiv, Mulx, DISsamples # current spin box value
7907  global SAMPLErate, contloop, discontloop, HtMulEntry
7908  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry, TgInput
7909  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7, COLORtraceR7 # The colors
7910  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6
7911  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6
7912  global CANVASwidth, CANVASheight
7913  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
7914  global ScreenTrefresh, SmoothCurves, Is_Triggered
7915  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
7916  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
7917  global InOffA, InGainA, InOffB, InGainB
7918  global CurOffA, CurOffB, CurGainA, CurGainB
7919  # Analog Mux channel measurement variables
7920  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
7921  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
7922  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
7923  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
7924  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
7925  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
7926  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
7927  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
7928  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
7929  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
7930  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
7931  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
7932  global AWGAShape, AWGBShape, MeasDiffAB, MeasDiffBA
7933  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7934  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
7935  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
7936  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
7937  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
7938  global DacScreenStatus, DigScreenStatus, CHA_RC_HP, CHB_RC_HP
7939  global D0, D1, D2, D3, D4, D5, D6, D7
7940  global DevID, devx, MarkerNum, MarkerScale, MeasGateLeft, MeasGateRight, MeasGateStatus
7941  global HozPoss, HozPossentry, First_Slow_sweep, Roll_Mode
7942  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
7943  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
7944  global CHBADelayR1, CHBADelayR2, CHBADelayF, MeasDelay
7945  #
7946  Ymin = Y0T # Minimum position of time grid (top)
7947  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
7948 
7949  # DISsamples = (10.0 * TIMEdiv) # grid width in time
7950  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
7951  # get the vertical ranges
7952  try:
7953  CH1pdvRange = float(eval(CHAsb.get()))
7954  except:
7955  CHAsb.delete(0,END)
7956  CHAsb.insert(0, CH1pdvRange)
7957  try:
7958  CH2pdvRange = float(eval(CHBsb.get()))
7959  except:
7960  CHBsb.delete(0,END)
7961  CHBsb.insert(0, CH2pdvRange)
7962  try:
7963  CH1IpdvRange = float(eval(CHAIsb.get()))
7964  except:
7965  CHAIsb.delete(0,END)
7966  CHAIsb.insert(0, CH1IpdvRange)
7967  try:
7968  CH2IpdvRange = float(eval(CHBIsb.get()))
7969  except:
7970  CHBIsb.delete(0,END)
7971  CHBIsb.insert(0, CH2IpdvRange)
7972  # get the vertical offsets
7973  try:
7974  CHAOffset = float(eval(CHAVPosEntry.get()))
7975  except:
7976  CHAVPosEntry.delete(0,END)
7977  CHAVPosEntry.insert(0, CHAOffset)
7978  try:
7979  CHAIOffset = float(eval(CHAIPosEntry.get()))
7980  except:
7981  CHAIPosEntry.delete(0,END)
7982  CHAIPosEntry.insert(0, CHAIOffset)
7983  try:
7984  CHBOffset = float(eval(CHBVPosEntry.get()))
7985  except:
7986  CHBVPosEntry.delete(0,END)
7987  CHBVPosEntry.insert(0, CHBOffset)
7988  try:
7989  CHBIOffset = float(eval(CHBIPosEntry.get()))
7990  except:
7991  CHBIPosEntry.delete(0,END)
7992  CHBIPosEntry.insert(0, CHBIOffset)
7993  try:
7994  HoldOff = float(eval(HoldOffentry.get()))
7995  if HoldOff < 0:
7996  HoldOff = 0
7997  except:
7998  HoldOffentry.delete(0,END)
7999  HoldOffentry.insert(0, HoldOff)
8000  if ETSDisp.get() > 0 or MinigenScreenStatus.get() > 0:
8001  try:
8002  Mulx = float(eval(HtMulEntry.get()))
8003  if Mulx < 1:
8004  Mulx = 1
8005  except:
8006  Mulx = 1
8007  if EnableHSsampling > 0:
8008  HtMulEntry.delete(0,END)
8009  HtMulEntry.insert(0, 1)
8010  else:
8011  Mulx = 1
8012  # slide trace left right by HozPoss
8013  try:
8014  HozPoss = float(eval(HozPossentry.get()))
8015  except:
8016  HozPossentry.delete(0,END)
8017  HozPossentry.insert(0, HozPoss)
8018  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
8019  try:
8020  CHMApdvRange = float(eval(CHB_Asb.get()))
8021  except:
8022  CHB_Asb.delete(0,END)
8023  CHB_Asb.insert(0, CHMApdvRange)
8024  try:
8025  CHMBpdvRange = float(eval(CHB_Bsb.get()))
8026  except:
8027  CHB_Bsb.delete(0,END)
8028  CHB_Bsb.insert(0, CHMBpdvRange)
8029  try:
8030  CHMCpdvRange = float(eval(CHB_Csb.get()))
8031  except:
8032  CHB_Csb.delete(0,END)
8033  CHB_Csb.insert(0, CHMCpdvRange)
8034  try:
8035  CHMDpdvRange = float(eval(CHB_Dsb.get()))
8036  except:
8037  CHB_Dsb.delete(0,END)
8038  CHB_Dsb.insert(0, CHMDpdvRange)
8039  if CHMApdvRange < 0.001:
8040  CHMApdvRange = 0.001
8041  if CHMBpdvRange < 0.001:
8042  CHMBpdvRange = 0.001
8043  if CHMCpdvRange < 0.001:
8044  CHMCpdvRange = 0.001
8045  if CHMDpdvRange < 0.001:
8046  CHMDpdvRange = 0.001
8047  try:
8048  CHBAOffset = float(eval(CHB_APosEntry.get()))
8049  except:
8050  CHB_APosEntry.delete(0,END)
8051  CHB_APosEntry.insert(0, CHBAOffset)
8052  try:
8053  CHBBOffset = float(eval(CHB_BPosEntry.get()))
8054  except:
8055  CHB_BPosEntry.delete(0,END)
8056  CHB_BPosEntry.insert(0, CHBBOffset)
8057  try:
8058  CHBCOffset = float(eval(CHB_CPosEntry.get()))
8059  except:
8060  CHB_CPosEntry.delete(0,END)
8061  CHB_CPosEntry.insert(0, CHBCOffset)
8062  try:
8063  CHBDOffset = float(eval(CHB_DPosEntry.get()))
8064  except:
8065  CHB_DPosEntry.delete(0,END)
8066  CHB_DPosEntry.insert(0, CHBDOffset)
8067  # prevent divide by zero error
8068  if CH1pdvRange < 0.001:
8069  CH1pdvRange = 0.001
8070  if CH2pdvRange < 0.001:
8071  CH2pdvRange = 0.001
8072  if CH1IpdvRange < 0.1:
8073  CH1IpdvRange = 0.1
8074  if CH2IpdvRange < 0.1:
8075  CH2IpdvRange = 0.1
8076  vt = HoldOff + HozPoss # invert sign and scale to mSec
8077  if ScreenTrefresh.get() == 0:
8078  # Delete all items on the screen
8079  ca.delete(ALL) # remove all items
8080  MarkerNum = 0
8081  # Draw horizontal grid lines
8082  i = 0
8083  x1 = X0L
8084  x2 = X0L + GRW
8085  mg_siz = GRW/10.0
8086  mg_inc = mg_siz/5.0
8087  MathFlag1 = (MathAxis == "V-A" and MathTrace.get() == 12) or (MathXAxis == "V-A" and Show_MathX.get() == 1) or (MathYAxis == "V-A" and Show_MathY.get() == 1)
8088  MathFlag2 = (MathAxis == "V-B" and MathTrace.get() == 12) or (MathXAxis == "V-B" and Show_MathX.get() == 1) or (MathYAxis == "V-B" and Show_MathY.get() == 1)
8089  MathFlag3 = (MathAxis == "I-A" and MathTrace.get() == 12) or (MathXAxis == "I-A" and Show_MathX.get() == 1) or (MathYAxis == "I-A" and Show_MathY.get() == 1)
8090  MathFlag4 = (MathAxis == "I-B" and MathTrace.get() == 12) or (MathXAxis == "I-B" and Show_MathX.get() == 1) or (MathYAxis == "I-B" and Show_MathY.get() == 1)
8091  # vertical scale text labels
8092  RightOffset = FontSize * 3
8093  LeftOffset = int(FontSize/2)
8094  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
8095  ca.create_text(x1-LeftOffset, 12, text="CA-V", fill=COLORtrace1, anchor="e", font=("arial", FontSize-1 ))
8096  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
8097  ca.create_text(x2+LeftOffset, 12, text="CA-I", fill=COLORtrace3, anchor="w", font=("arial", FontSize-1 ))
8098  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
8099  ca.create_text(x1-RightOffset+2, 12, text="CB-V", fill=COLORtrace2, anchor="e", font=("arial", FontSize-1 )) #26
8100  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
8101  ca.create_text(x2+RightOffset+4, 12, text="CB-I", fill=COLORtrace4, anchor="w", font=("arial", FontSize-1 )) #28
8102  #
8103  while (i < 11):
8104  y = Y0T + i * GRH/10.0
8105  Dline = [x1,y,x2,y]
8106  if i == 5:
8107  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
8108  k = 0
8109  while (k < 10):
8110  l = 1
8111  while (l < 5):
8112  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
8113  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8114  l = l + 1
8115  k = k + 1
8116  else:
8117  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8118 
8119  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
8120  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8121  # Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
8122  Vaxis_label = str(round(Vaxis_value,3 ))
8123  ca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
8124 
8125  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
8126  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8127  Iaxis_label = str(round(Iaxis_value, 3))
8128  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
8129 
8130  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
8131  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8132  Vaxis_label = str(round(Vaxis_value, 3))
8133  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
8134 
8135  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
8136  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8137  Iaxis_label = str(round(Iaxis_value, 3))
8138  ca.create_text(x2+RightOffset+4, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 28
8139  if MuxScreenStatus.get() == 1:
8140  if Show_CBA.get() == 1:
8141  Vaxis_value = (((5-i) * CHMApdvRange ) + CHBAOffset)
8142  Vaxis_label = str(round(Vaxis_value, 3))
8143  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
8144  if Show_CBB.get() == 1:
8145  Iaxis_value = 1.0 * (((5-i) * CHMBpdvRange ) + CHBBOffset)
8146  Iaxis_label = str(round(Iaxis_value, 3))
8147  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace6, anchor="w", font=("arial", FontSize ))
8148  if Show_CBC.get() == 1:
8149  Iaxis_value = 1.0 * (((5-i) * CHMCpdvRange ) + CHBCOffset)
8150  Iaxis_label = str(round(Iaxis_value, 3))
8151  ca.create_text(x2+RightOffset-3, y, text=Iaxis_label, fill=COLORtrace7, anchor="w", font=("arial", FontSize )) # 21
8152  if Show_CBD.get() == 1:
8153  Iaxis_value = 1.0 * (((5-i) * CHMDpdvRange ) + CHBDOffset)
8154  Iaxis_label = str(round(Iaxis_value, 3))
8155  ca.create_text(x2+RightOffset+10, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 38
8156  i = i + 1
8157  # Draw vertical grid lines
8158  i = 0
8159  y1 = Y0T
8160  y2 = Y0T + GRH
8161  mg_siz = GRH/10.0
8162  mg_inc = mg_siz/5.0
8163  vx = TIMEdiv/Mulx
8164  vt = HoldOff/Mulx # invert sign and scale to mSec
8165  # vx = TIMEdiv
8166  while (i < 11):
8167  x = X0L + i * GRW/10.0
8168  Dline = [x,y1,x,y2]
8169  if (i == 5):
8170  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
8171  k = 0
8172  while (k < 10):
8173  l = 1
8174  while (l < 5):
8175  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
8176  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8177  l = l + 1
8178  k = k + 1
8179  #
8180  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8181  if vx >= 1000:
8182  axis_value = ((i * vx)+ vt) / 1000.0
8183  axis_label = ' {0:.1f} '.format(axis_value) + " S"
8184  if vx < 1000 and vx >= 1:
8185  axis_value = (i * vx) + vt
8186  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
8187  if vx < 1:
8188  axis_value = ((i * vx) + vt) * 1000.0
8189  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
8190  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
8191  else:
8192  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8193  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8194  if vx >= 1000:
8195  axis_value = ((i * vx)+ vt) / 1000.0
8196  axis_label = ' {0:.1f} '.format(axis_value) + " S"
8197  if vx < 1000 and vx >= 1:
8198  axis_value = (i * vx) + vt
8199  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
8200  if vx < 1:
8201  axis_value = ((i * vx) + vt) * 1000.0
8202  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
8203  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
8204 
8205  i = i + 1
8206  # Write the trigger line if available
8207  if Roll_Mode.get() == 0: # Don't show trigger indicator when in Roll Mode
8208  if len(Triggerline) > 2: # Avoid writing lines with 1 coordinate
8209  ca.create_polygon(Triggerline, outline=COLORtrigger, fill=COLORtrigger, width=1)
8210  ca.create_line(Triggersymbol, fill=COLORtrigger, width=GridWidth.get())
8211  if TgInput.get() == 1:
8212  TgLabel = "CA-V"
8213  if TgInput.get() == 2:
8214  TgLabel = "CA-I"
8215  if TgInput.get() == 3:
8216  TgLabel = "CB-V"
8217  if TgInput.get() == 4:
8218  TgLabel = "CB-I"
8219  if TgInput.get() == 5:
8220  TgLabel = "VA or VB"
8221  if TgInput.get() == 6:
8222  TgLabel = "Alternate"
8223  if ChopTrig.get() == 1:
8224  TgLabel = "Mux A"
8225  if ChopTrig.get() == 2:
8226  TgLabel = "Mux B"
8227  if ChopTrig.get() == 3:
8228  TgLabel = "Mux C"
8229  if ChopTrig.get() == 4:
8230  TgLabel = "Mux D"
8231  if Is_Triggered == 1:
8232  TgLabel = TgLabel + " Triggered"
8233  else:
8234  TgLabel = TgLabel + " Not Triggered"
8235  if SingleShot.get() > 0:
8236  TgLabel = TgLabel + " Armed"
8237  x = X0L + (GRW/2) + 12
8238  ca.create_text(x, Ymin-FontSize, text=TgLabel, fill=COLORtrigger, anchor="w", font=("arial", FontSize ))
8239  # Draw T - V Cursor lines if required
8240  if MarkerScale.get() == 0:
8241  Yconv1 = float(GRH/10.0) / CH1pdvRange
8242  Yoffset1 = CHAOffset
8243  COLORmarker = COLORtrace1
8244  Units = " V"
8245  if MarkerScale.get() == 1:
8246  MouseY = MouseCAV
8247  Yconv1 = float(GRH/10.0) / CH1pdvRange
8248  Yoffset1 = CHAOffset
8249  COLORmarker = COLORtrace1
8250  Units = " V"
8251  if MarkerScale.get() == 2:
8252  MouseY = MouseCBV
8253  Yconv1 = float(GRH/10.0) / CH2pdvRange
8254  Yoffset1 = CHBOffset
8255  COLORmarker = COLORtrace2
8256  Units = " V"
8257  if MarkerScale.get() == 3:
8258  MouseY = MouseCAI
8259  Yconv1 = float(GRH/10.0) / CH1IpdvRange
8260  Yoffset1 = CHAIOffset
8261  COLORmarker = COLORtrace3
8262  Units = " mA"
8263  if MarkerScale.get() == 4:
8264  MouseY = MouseCBI
8265  Yconv1 = float(GRH/10.0) / CH2IpdvRange
8266  Yoffset1 = CHBIOffset
8267  COLORmarker = COLORtrace4
8268  Units = " mA"
8269  # Analog Mux settings
8270  if MarkerScale.get() == 5:
8271  MouseY = MouseMuxA
8272  Yconv1 = float(GRH/10.0) / CHMApdvRange
8273  Yoffset1 = CHBAOffset
8274  COLORmarker = COLORtrace2
8275  Units = " V"
8276  if MarkerScale.get() == 6:
8277  MouseY = MouseMuxB
8278  Yconv1 = float(GRH/10.0) / CHMBpdvRange
8279  Yoffset1 = CHBBOffset
8280  COLORmarker = COLORtrace6
8281  Units = " V"
8282  if MarkerScale.get() == 7:
8283  MouseY = MouseMuxC
8284  Yconv1 = float(GRH/10.0) / CHMCpdvRange
8285  Yoffset1 = CHBCOffset
8286  COLORmarker = COLORtrace7
8287  Units = " V"
8288  if MarkerScale.get() == 8:
8289  MouseY = MouseMuxD
8290  Yconv1 = float(GRH/10.0) / CHMDpdvRange
8291  Yoffset1 = CHBDOffset
8292  COLORmarker = COLORtrace4
8293  Units = " V"
8294 #
8295  if ShowTCur.get() > 0:
8296  Dline = [TCursor, Y0T, TCursor, Y0T+GRH]
8297  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
8298  Tpoint = ((TCursor-X0L) * Tstep) + vt
8299  Tpoint = Tpoint/Mulx
8300  if Tpoint >= 1000:
8301  axis_value = Tpoint / 1000.0
8302  V_label = ' {0:.2f} '.format(axis_value) + " S"
8303  if Tpoint < 1000 and Tpoint >= 1:
8304  axis_value = Tpoint
8305  V_label = ' {0:.2f} '.format(axis_value) + " mS"
8306  if Tpoint < 1:
8307  axis_value = Tpoint * 1000.0
8308  V_label = ' {0:.2f} '.format(axis_value) + " uS"
8309  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8310  ca.create_text(TCursor, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
8311  if ShowVCur.get() > 0:
8312  Dline = [X0L, VCursor, X0L+GRW, VCursor]
8313  ca.create_line(Dline, dash=(4,3), fill=COLORmarker, width=GridWidth.get())
8314  c1 = GRH / 2 + Y0T # fixed Y correction
8315  yvolts = ((VCursor-c1)/Yconv1) - Yoffset1
8316  V1String = ' {0:.3f} '.format(-yvolts)
8317  V_label = V1String + Units
8318  ca.create_text(X0L+GRW+2, VCursor, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
8319  if ShowTCur.get() == 0 and ShowVCur.get() == 0 and MouseWidget == ca:
8320  if MouseX > X0L and MouseX < X0L+GRW and MouseY > Y0T and MouseY < Y0T+GRH:
8321  Dline = [MouseX, Y0T, MouseX, Y0T+GRH]
8322  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
8323  ca.create_oval(MouseX-GridWidth.get(), MouseY-GridWidth.get(), MouseX+GridWidth.get(), MouseY+GridWidth.get(), outline=COLORtrigger, fill=COLORtrigger, width=GridWidth.get())
8324  Tpoint = ((MouseX-X0L) * Tstep) + vt
8325  Tpoint = Tpoint/Mulx
8326  if Tpoint >= 1000:
8327  axis_value = Tpoint / 1000.0
8328  V_label = ' {0:.2f} '.format(axis_value) + " S"
8329  if Tpoint < 1000 and Tpoint >= 1:
8330  axis_value = Tpoint
8331  V_label = ' {0:.2f} '.format(axis_value) + " mS"
8332  if Tpoint < 1:
8333  axis_value = Tpoint * 1000.0
8334  V_label = ' {0:.2f} '.format(axis_value) + " uS"
8335  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8336  ca.create_text(MouseX, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
8337  Dline = [X0L, MouseY, X0L+GRW, MouseY]
8338  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
8339  c1 = GRH / 2 + Y0T # fixed Y correction
8340  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
8341  V1String = ' {0:.3f} '.format(-yvolts)
8342  V_label = V1String + Units
8343  ca.create_text(X0L+GRW+2, MouseY, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
8344 #
8345  if MeasGateStatus.get() == 1:
8346  LeftGate = X0L + MeasGateLeft / Tstep
8347  RightGate = X0L + MeasGateRight / Tstep
8348  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace5)
8349  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace7)
8350  #
8351  # TString = ' {0:.2f} '.format(Tpoint)
8352  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8353  DT = (MeasGateRight-MeasGateLeft)/Mulx
8354  if DT == 0.0:
8355  DT = 1.0
8356  if DT >= 1000:
8357  axis_value = DT / 1000.0
8358  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
8359  if DT < 1000 and DT >= 1:
8360  axis_value = DT
8361  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
8362  if DT < 1:
8363  axis_value = DT * 1000.0
8364  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
8365  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
8366  DFreq = ' {0:.3f} '.format(1.0/DT)
8367  V_label = " Delta T" + DeltaT
8368  #V_label = V_label + Units
8369  V_label = V_label + ", Freq " + DFreq + " KHz"
8370  # place in upper left unless specified otherwise
8371  TxScale = FontSize + 2
8372  x = X0L + 5
8373  y = Y0T + 7
8374  Justify = 'w'
8375  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
8376  x = X0L + GRW - 5
8377  y = Y0T + 7
8378  Justify = 'e'
8379  if MarkerLoc == 'LL' or MarkerLoc == 'll':
8380  x = X0L + 5
8381  y = Y0T + GRH + 7 - (MarkerNum*TxScale)
8382  Justify = 'w'
8383  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
8384  x = X0L + GRW - 5
8385  y = Y0T + GRH + 7
8386  Justify = 'e'
8387  ca.create_text(x, y, text=V_label, fill=COLORtrace5, anchor=Justify, font=("arial", FontSize ))
8388  #
8389 #
8390  SmoothBool = SmoothCurves.get()
8391  # Write the traces if available
8392  if len(T1Vline) > 4: # Avoid writing lines with 1 coordinate
8393  ca.create_line(T1Vline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the voltage trace 1
8394  if len(T1Iline) > 4: # Avoid writing lines with 1 coordinate
8395  ca.create_line(T1Iline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the current trace 1
8396  if len(T2Vline) > 4: # Write the trace 2 if active
8397  ca.create_line(T2Vline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8398  if len(T2Iline) > 4:
8399  ca.create_line(T2Iline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8400  if len(Tmathline) > 4 and MathTrace.get() > 0: # Write Math tace if active
8401  ca.create_line(Tmathline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8402  if len(TMXline) > 4 : # Write X Math tace if active
8403  ca.create_line(TMXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8404  if len(TMYline) > 4 : # Write Y Math tace if active
8405  ca.create_line(TMYline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8406  if MuxScreenStatus.get() == 1:
8407  if len(TMAVline) > 4: # Avoid writing lines with 1 coordinate
8408  ca.create_line(TMAVline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8409  if len(TMBVline) > 4: # Avoid writing lines with 1 coordinate
8410  ca.create_line(TMBVline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8411  if len(TMCVline) > 4: # Avoid writing lines with 1 coordinate
8412  ca.create_line(TMCVline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8413  if len(TMDVline) > 4: # Avoid writing lines with 1 coordinate
8414  ca.create_line(TMDVline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8415  if ShowRMA.get() == 1 and len(TMARline) > 4:
8416  ca.create_line(TMARline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8417  if ShowRMB.get() == 1 and len(TMBRline) > 4:
8418  ca.create_line(TMBRline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8419  if ShowRMC.get() == 1 and len(TMCRline) > 4:
8420  ca.create_line(TMCRline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8421  if ShowRMD.get() == 1 and len(TMDRline) > 4:
8422  ca.create_line(TMDRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8423  if ShowRA_V.get() == 1 and len(T1VRline) > 4:
8424  ca.create_line(T1VRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8425  if ShowRA_I.get() == 1 and len(T1IRline) > 4:
8426  ca.create_line(T1IRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8427  if ShowRB_V.get() == 1 and len(T2VRline) > 4:
8428  ca.create_line(T2VRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8429  if ShowRB_I.get() == 1 and len(T2IRline) > 4:
8430  ca.create_line(T2IRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8431  if ShowMath.get() == 1 and len(TMRline) > 4:
8432  ca.create_line(TMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8433  if First_Slow_sweep == 1:
8434  # print(len(D0line),len(D1line), len(D2line), len(D3line))
8435  if D0.get() == 0:
8436  ca.create_line(D0line, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8437  if D1.get() == 0:
8438  ca.create_line(D1line, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8439  if D2.get() == 0:
8440  ca.create_line(D2line, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8441  if D3.get() == 0:
8442  ca.create_line(D3line, fill=COLORzeroline, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8443  # General information on top of the grid
8444  # Sweep information
8445  if session.continuous:
8446  sttxt = "Running Continuous"
8447  else:
8448  sttxt = "Running Discontinuous"
8449  if TRACEmodeTime.get() == 1:
8450  sttxt = sttxt + " Averaging"
8451  if ManualTrigger.get() == 1:
8452  sttxt = "Manual Trigger"
8453  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
8454  sttxt = "Stopped"
8455  if ScreenTrefresh.get() == 1:
8456  sttxt = sttxt + " Persistance ON"
8457  # Delete text at bottom of screen
8458  de = ca.find_enclosed( X0L-1, Y0T+GRH+12, CANVASwidth, Y0T+GRH+100)
8459  for n in de:
8460  ca.delete(n)
8461  # Delete text at top of screen
8462  de = ca.find_enclosed( X0L-1, -1, CANVASwidth, 20)
8463  for n in de:
8464  ca.delete(n)
8465  if Roll_Mode.get() == 0:
8466  if LabelPlotText.get() > 0:
8467  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8468  else:
8469  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8470  else:
8471  if LabelPlotText.get() > 0:
8472  txt = PlotLabelText + " Rolling Sweep " + sttxt
8473  else:
8474  txt = "Device ID " + DevID[17:31] + " Rolling Sweep " + sttxt
8475  x = X0L+2
8476  y = 12
8477  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
8478  # digital I/O indicators
8479  x2 = X0L + GRW
8480  BoxColor = "#808080" # gray
8481  if DacScreenStatus.get() == 0 and (DigScreenStatus.get() == 1 or MuxScreenStatus.get() == 1):
8482  if D0.get() == 0 and D4.get() == 0:
8483  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
8484  if Dval[0] == 1:
8485  BoxColor = "#00ff00" # 100% green
8486  elif Dval[0] == 0:
8487  BoxColor = "#ff0000" # 100% red
8488  ca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
8489  else:
8490  ca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
8491  if D1.get() == 0 and D5.get() == 0:
8492  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
8493  if Dval[0] == 1:
8494  BoxColor = "#00ff00" # 100% green
8495  elif Dval[0] == 0:
8496  BoxColor = "#ff0000" # 100% red
8497  ca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
8498  else:
8499  ca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
8500  if D2.get() == 0 and D6.get() == 0:
8501  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
8502  if Dval[0] == 1:
8503  BoxColor = "#00ff00" # 100% green
8504  elif Dval[0] == 0:
8505  BoxColor = "#ff0000" # 100% red
8506  ca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
8507  else:
8508  ca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
8509  if D3.get() == 0 and D7.get() == 0:
8510  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
8511  if Dval[0] == 1:
8512  BoxColor = "#00ff00" # 100% green
8513  elif Dval[0] == 0:
8514  BoxColor = "#ff0000" # 100% red
8515  ca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
8516  else:
8517  ca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
8518  ca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext, font=("arial", FontSize ))
8519  # Time sweep information and view at information
8520  vx = TIMEdiv/Mulx
8521  if vx >= 1000:
8522  txt = ' {0:.2f} '.format(vx / 1000.0) + " S/div"
8523  if vx < 1000 and vx >= 1:
8524  txt = ' {0:.2f} '.format(vx) + " mS/div"
8525  if vx < 1:
8526  txt = ' {0:.2f} '.format(vx * 1000.0) + " uS/div"
8527 
8528  txt = txt + " "
8529  #
8530  txt = txt + "View at "
8531  if abs(vt) >= 1000:
8532  txt = txt + str(int(vt / 1000.0)) + " S "
8533  if abs(vt) < 1000 and abs(vt) >= 1:
8534  txt = txt + str(int(vt)) + " mS "
8535  if abs(vt) < 1:
8536  txt = txt + str(int(vt * 1000.0)) + " uS "
8537  # print period and frequency of displayed channels
8538  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
8539  if ETSDisp.get() > 0:
8540  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
8541  else:
8542  if MeasGateStatus.get() == 1:
8543  if (MeasGateRight-MeasGateLeft) > 0:
8544  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
8545  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
8546  if Endsample <= hldn:
8547  Endsample = hldn + 2
8548  FindRisingEdge(VBuffA[hldn:Endsample],VBuffB[hldn:Endsample])
8549  else:
8550  FindRisingEdge(VBuffA,VBuffB)
8551  if ShowC1_V.get() == 1:
8552  if MeasAHW.get() == 1:
8553  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
8554  if MeasALW.get() == 1:
8555  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
8556  if MeasADCy.get() == 1:
8557  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
8558  if MeasAPER.get() == 1:
8559  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
8560  if MeasAFREQ.get() == 1:
8561  txt = txt + " CA Freq = "
8562  ChaF = CHAfreq*Mulx
8563  if ChaF < 1000:
8564  V1String = ' {0:.1f} '.format(ChaF)
8565  txt = txt + str(V1String) + " Hz "
8566  if ChaF > 1000 and ChaF < 1000000:
8567  V1String = ' {0:.1f} '.format(ChaF/1000)
8568  txt = txt + str(V1String) + " KHz "
8569  if ChaF > 1000000:
8570  V1String = ' {0:.1f} '.format(ChaF/1000000)
8571  txt = txt + str(V1String) + " MHz "
8572  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
8573  if ShowC2_V.get() == 1:
8574  if MeasBHW.get() == 1:
8575  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
8576  if MeasBLW.get() == 1:
8577  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
8578  if MeasBDCy.get() == 1:
8579  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
8580  if MeasBPER.get() == 1:
8581  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
8582  if MeasBFREQ.get() == 1:
8583  txt = txt + " CB Freq = "
8584  ChaF = CHBfreq*Mulx
8585  if ChaF < 1000:
8586  V1String = ' {0:.1f} '.format(ChaF)
8587  txt = txt + str(V1String) + " Hz "
8588  if ChaF > 1000 and ChaF < 1000000:
8589  V1String = ' {0:.1f} '.format(ChaF/1000)
8590  txt = txt + str(V1String) + " KHz "
8591  if ChaF > 1000000:
8592  V1String = ' {0:.1f} '.format(ChaF/1000000)
8593  txt = txt + str(V1String) + " MHz "
8594  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
8595  if MuxScreenStatus.get() == 0:
8596  if MeasPhase.get() == 1:
8597  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8598  if MeasDelay.get() == 1:
8599  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8600 
8601  x = X0L
8602  y = Y0T+GRH+int(2.5 *FontSize) # 20
8603  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
8604  if MeasTopV1.get() == 1 or MeasBaseV1.get() == 1 or MeasTopV2.get() == 1 or MeasBaseV2.get() == 1:
8605  MakeHistogram()
8606  txt = " "
8607  if ShowC1_V.get() == 1:
8608  # Channel A information
8609  if CHA_RC_HP.get() == 1:
8610  txt = "CHA: HP "
8611  else:
8612  txt = "CHA: "
8613  txt = txt + str(CH1pdvRange) + " V/div"
8614  if MeasDCV1.get() == 1:
8615  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
8616  if MeasMaxV1.get() == 1:
8617  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
8618  if MeasTopV1.get() == 1:
8619  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
8620  if MeasMinV1.get() == 1:
8621  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
8622  if MeasBaseV1.get() == 1:
8623  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
8624  if MeasMidV1.get() == 1:
8625  MidV1 = (MaxV1+MinV1)/2.0
8626  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
8627  if MeasPPV1.get() == 1:
8628  PPV1 = MaxV1-MinV1
8629  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
8630  if MeasRMSV1.get() == 1:
8631  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
8632  if MeasRMSVA_B.get() == 1:
8633  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
8634  if MeasDiffAB.get() == 1:
8635  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
8636  if MeasUserA.get() == 1:
8637  try:
8638  TempValue = eval(UserAString)
8639  V1String = ' {0:.4f} '.format(TempValue)
8640  except:
8641  V1String = "####"
8642  txt = txt + UserALabel + " = " + V1String
8643  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
8644  txt = "CHA: "
8645  txt = txt + str(CH1IpdvRange) + " mA/div"
8646  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
8647  txt = txt + "CHA: "
8648  txt = txt + str(CH1IpdvRange) + " mA/div"
8649  if ShowC1_I.get() == 1:
8650  if MeasDCI1.get() == 1:
8651  V1String = ' {0:.2f} '.format(DCI1)
8652  txt = txt + " AvgI = " + V1String
8653  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
8654  try:
8655  Resvalue = (DCV1/DCI1)*1000
8656  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8657  except:
8658  txt = txt + " Res = OverRange"
8659  if MeasMaxI1.get() == 1:
8660  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
8661  if MeasMinI1.get() == 1:
8662  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
8663  if MeasMidI1.get() == 1:
8664  MidI1 = (MaxI1+MinI1)/2.0
8665  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
8666  if MeasPPI1.get() == 1:
8667  PPI1 = MaxI1-MinI1
8668  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
8669  if MeasRMSI1.get() == 1:
8670  txt = txt + " RMS = " + ' {0:.2f} '.format(SI1)
8671 
8672  x = X0L
8673  y = Y0T+GRH+(4*FontSize) # 32
8674  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
8675  txt= " "
8676  # Channel B information
8677  if MuxScreenStatus.get() == 1:
8678  txt = "CHB-Mux: "
8679  if Show_CBA.get() > 0:
8680  FindRisingEdge(VBuffA,VBuffMA)
8681  elif Show_CBB.get() > 0:
8682  FindRisingEdge(VBuffA,VBuffMB)
8683  elif Show_CBC.get() > 0:
8684  FindRisingEdge(VBuffA,VBuffMC)
8685  elif Show_CBD.get() > 0:
8686  FindRisingEdge(VBuffA,VBuffMD)
8687  if MeasPhase.get() == 1:
8688  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8689  if MeasDelay.get() == 1:
8690  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8691  if MeasUserB.get() == 1:
8692  try:
8693  TempValue = eval(UserBString)
8694  V1String = ' {0:.4f} '.format(TempValue)
8695  except:
8696  V1String = "####"
8697  txt = txt + UserBLabel + " = " + V1String
8698  if ShowC2_V.get() == 1:
8699  if CHB_RC_HP.get() == 1:
8700  txt = "CHB: HP "
8701  else:
8702  txt = "CHB: "
8703  txt = txt + str(CH2pdvRange) + " V/div"
8704  if MeasDCV2.get() == 1:
8705  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
8706  if MeasMaxV2.get() == 1:
8707  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
8708  if MeasTopV2.get() == 1:
8709  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
8710  if MeasMinV2.get() == 1:
8711  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
8712  if MeasBaseV2.get() == 1:
8713  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
8714  if MeasMidV2.get() == 1:
8715  MidV2 = (MaxV2+MinV2)/2.0
8716  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
8717  if MeasPPV2.get() == 1:
8718  PPV2 = MaxV2-MinV2
8719  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
8720  if MeasRMSV2.get() == 1:
8721  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
8722  if MeasDiffBA.get() == 1:
8723  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
8724  if MeasUserB.get() == 1:
8725  try:
8726  TempValue = eval(UserBString)
8727  V1String = ' {0:.4f} '.format(TempValue)
8728  except:
8729  V1String = "####"
8730  txt = txt + UserBLabel + " = " + V1String
8731  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
8732  txt = "CHB: "
8733  txt = txt + str(CH2IpdvRange) + " mA/div"
8734  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
8735  txt = txt + "CHB: "
8736  txt = txt + str(CH2IpdvRange) + " mA/div"
8737  if ShowC2_I.get() == 1:
8738  if MeasDCI2.get() == 1:
8739  V1String = ' {0:.2f} '.format(DCI2)
8740  txt = txt + " AvgI = " + V1String
8741  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
8742  try:
8743  Resvalue = (DCV2/DCI2)*1000
8744  R1String = ' {0:.1f} '.format(Resvalue)
8745  txt = txt + " Res = " + R1String
8746  except:
8747  txt = txt + " Res = OverRange"
8748  if MeasMaxI2.get() == 1:
8749  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
8750  if MeasMinI2.get() == 1:
8751  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
8752  if MeasMidI2.get() == 1:
8753  MidI2 = (MaxI2+MinI2)/2.0
8754  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
8755  if MeasPPI2.get() == 1:
8756  PPI2 = MaxI2-MinI2
8757  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
8758  if MeasRMSI2.get() == 1:
8759  txt = txt + " RMS = " + ' {0:.2f} '.format(SI2)
8760 
8761  x = X0L
8762  y = Y0T+GRH+int(5.5*FontSize) # 44
8763  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
8764 
8765 def MakeXYScreen():
8766  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY # active trave lines
8767  global Tmathline, TMRline, XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
8768  global X0LXY # Left top X value
8769  global Y0TXY # Left top Y value
8770  global GRWXY # Screenwidth
8771  global GRHXY # Screenheight
8772  global FontSize, LabelPlotText, PlotLabelText
8773  global XYca, MouseX, MouseY, MouseWidget
8774  global ShowXCur, ShowYCur, XCursor, YCursor
8775  global SHOWsamples # Number of samples in data record
8776  global ShowMath, MathUnits, MathXUnits, MathYUnits
8777  global Xsignal, MathAxis, MathXAxis, MathYAxis
8778  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMY, YsignalMX
8779  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
8780  global RUNstatus, SingleShot, ManualTrigger # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
8781  global CHAsbxy # spinbox Index for channel 1 V
8782  global CHBsbxy # spinbox Index for channel 2 V
8783  global CHAOffset # Offset value for channel 1 V
8784  global CHBOffset # Offset value for channel 2 V
8785  global CHAIsbxy # spinbox Index for channel 1 I
8786  global CHBIsbxy # spinbox Index for channel 2 I
8787  global CHAIOffset # Offset value for channel 1 I
8788  global CHBIOffset # Offset value for channel 2 I
8789  global TMpdiv # Array with time / div values in ms
8790  global TMsb # Time per div spin box variable
8791  global TIMEdiv # current spin box value
8792  global SAMPLErate
8793  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry
8794  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace6, COLORtrace7 # The colors
8795  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5
8796  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6, COLORtraceR7
8797  global CANVASwidthXY, CANVASheightXY, COLORXmarker, COLORYmarker
8798  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
8799  global ScreenXYrefresh, SmoothCurves
8800  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
8801  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
8802  global SV1, SI1, SV2, SI2, CHABphase
8803  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
8804  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
8805  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
8806  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
8807  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase
8808  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
8809  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
8810  global AWGAShape, AWGBShape
8811  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
8812  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
8813  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
8814  global DacScreenStatus, DigScreenStatus
8815  global D0, D1, D2, D3, D4, D5, D6, D7
8816  global DevID, devx, MarkerNum, MarkerScale
8817  global HozPoss, HozPossentry
8818  global HistAsPercent, VBuffA, VBuffB, HBuffA, HBuffB
8819  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
8820  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
8821  #
8822  Ymin = Y0TXY # Minimum position of screen grid (top)
8823  Ymax = Y0TXY + GRHXY # Maximum position of screen grid (bottom)
8824  RightOffset = FontSize * 3
8825  LeftOffset = int(FontSize/2)
8826  try:
8827  InOffA = float(eval(CHAVOffsetEntry.get()))
8828  except:
8829  CHAVOffsetEntry.delete(0,END)
8830  CHAVOffsetEntry.insert(0, InOffA)
8831  try:
8832  InGainA = float(eval(CHAVGainEntry.get()))
8833  except:
8834  CHAVGainEntry.delete(0,END)
8835  CHAVGainEntry.insert(0, InGainA)
8836  try:
8837  InOffB = float(eval(CHBVOffsetEntry.get()))
8838  except:
8839  CHBVOffsetEntry.delete(0,END)
8840  CHBVOffsetEntry.insert(0, InOffB)
8841  try:
8842  InGainB = float(eval(CHBVGainEntry.get()))
8843  except:
8844  CHBVGainEntry.delete(0,END)
8845  CHBVGainEntry.insert(0, InGainB)
8846 #
8847  try:
8848  CH1pdvRange = float(eval(CHAsbxy.get()))
8849  except:
8850  CHAsbxy.delete(0,END)
8851  CHAsbxy.insert(0, CH1pdvRange)
8852  try:
8853  CH2pdvRange = float(eval(CHBsbxy.get()))
8854  except:
8855  CHBsbxy.delete(0,END)
8856  CHBsbxy.insert(0, CH2pdvRange)
8857  try:
8858  CH1IpdvRange = float(eval(CHAIsbxy.get()))
8859  except:
8860  CHAIsbxy.delete(0,END)
8861  CHAIsbxy.insert(0, CH1IpdvRange)
8862  try:
8863  CH2IpdvRange = float(eval(CHBIsbxy.get()))
8864  except:
8865  CHBIsbxy.delete(0,END)
8866  CHBIsbxy.insert(0, CH2IpdvRange)
8867  # get the vertical offsets
8868  try:
8869  CHAOffset = float(eval(CHAVPosEntryxy.get()))
8870  except:
8871  CHAVPosEntryxy.delete(0,END)
8872  CHAVPosEntryxy.insert(0, CHAOffset)
8873  try:
8874  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
8875  except:
8876  CHAIPosEntryxy.delete(0,END)
8877  CHAIPosEntryxy.insert(0, CHAIOffset)
8878  try:
8879  CHBOffset = float(eval(CHBVPosEntryxy.get()))
8880  except:
8881  CHBVPosEntry.delete(0,END)
8882  CHBVPosEntry.insert(0, CHBOffset)
8883  try:
8884  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
8885  except:
8886  CHBIPosEntryxy.delete(0,END)
8887  CHBIPosEntryxy.insert(0, CHBIOffset)
8888  # prevent divide by zero error
8889  if CH1pdvRange < 0.001:
8890  CH1pdvRange = 0.001
8891  if CH2pdvRange < 0.001:
8892  CH2pdvRange = 0.001
8893  if CH1IpdvRange < 0.05:
8894  CH1IpdvRange = 0.05
8895  if CH2IpdvRange < 0.05:
8896  CH2IpdvRange = 0.05
8897  # If drawing histograms adjust offset based on range such that bottom grid is zero
8898  if Xsignal.get() == 6:
8899  CHAIOffset = 5 * CH1IpdvRange
8900  if Xsignal.get() == 7:
8901  CHBIOffset = 5 * CH2IpdvRange
8902  if ScreenXYrefresh.get() == 0:
8903  # Delete all items on the screen
8904  MarkerNum = 0
8905  XYca.delete(ALL) # remove all items
8906  # Draw horizontal grid lines
8907  i = 0
8908  x1 = X0LXY
8909  x2 = X0LXY + GRWXY
8910  mg_siz = GRWXY/10.0
8911  mg_inc = mg_siz/5.0
8912  while (i < 11):
8913  y = Y0TXY + i * GRHXY/10.0
8914  Dline = [x1,y,x2,y]
8915  if i == 5:
8916  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
8917  k = 0
8918  while (k < 10):
8919  l = 1
8920  while (l < 5):
8921  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
8922  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8923  l = l + 1
8924  k = k + 1
8925  else:
8926  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8927  if YsignalIA.get() == 1 or Xsignal.get() == 6:
8928  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8929  Iaxis_label = str(round(Iaxis_value, 3))
8930  XYca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
8931  if YsignalIB.get() == 1 or Xsignal.get() == 7:
8932  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8933  Iaxis_label = str(round(Iaxis_value, 3))
8934  XYca.create_text(x2+RightOffset, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize ))
8935  if YsignalVA.get() == 1:
8936  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8937  Vaxis_label = str(round(Vaxis_value, 3))
8938  XYca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
8939  if YsignalVB.get() == 1:
8940  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8941  Vaxis_label = str(round(Vaxis_value, 3))
8942  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize ))
8943  if YsignalM.get() == 1:
8944  TempCOLOR = COLORtrace5
8945  if MathTrace.get() == 2:
8946  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8947  elif MathTrace.get() == 3:
8948  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8949  else:
8950  if MathAxis == "V-A":
8951  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8952  TempCOLOR = COLORtrace1
8953  elif MathAxis == "V-B":
8954  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8955  TempCOLOR = COLORtrace2
8956  elif MathAxis == "I-A":
8957  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8958  TempCOLOR = COLORtrace3
8959  elif MathAxis == "I-B":
8960  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8961  TempCOLOR = COLORtrace4
8962  else:
8963  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8964  Vaxis_label = str(round(Vaxis_value, 3))
8965  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8966  if YsignalMX.get() == 1:
8967  TempCOLOR = COLORtrace6
8968  if MathXAxis == "V-A":
8969  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8970  TempCOLOR = COLORtrace1
8971  elif MathXAxis == "V-B":
8972  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8973  TempCOLOR = COLORtrace2
8974  elif MathXAxis == "I-A":
8975  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8976  TempCOLOR = COLORtrace3
8977  elif MathXAxis == "I-B":
8978  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8979  TempCOLOR = COLORtrace4
8980  else:
8981  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8982  Vaxis_label = str(round(Vaxis_value, 3))
8983  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8984  if YsignalMY.get() == 1:
8985  TempCOLOR = COLORtrace7
8986  if MathYAxis == "V-A":
8987  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8988  TempCOLOR = COLORtrace1
8989  elif MathYAxis == "V-B":
8990  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8991  TempCOLOR = COLORtrace2
8992  elif MathYAxis == "I-A":
8993  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8994  TempCOLOR = COLORtrace3
8995  elif MathYAxis == "I-B":
8996  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8997  TempCOLOR = COLORtrace4
8998  else:
8999  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
9000  Vaxis_label = str(round(Vaxis_value, 3))
9001  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
9002  i = i + 1
9003  # Draw vertical grid lines
9004  i = 0
9005  y1 = Y0TXY
9006  y2 = Y0TXY + GRHXY
9007  mg_siz = GRHXY/10.0
9008  mg_inc = mg_siz/5.0
9009  #
9010  while (i < 11):
9011  x = X0LXY + i * GRWXY/10.0
9012  Dline = [x,y1,x,y2]
9013  if (i == 5):
9014  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
9015  k = 0
9016  while (k < 10):
9017  l = 1
9018  while (l < 5):
9019  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
9020  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
9021  l = l + 1
9022  k = k + 1
9023  if Xsignal.get() == 1 or Xsignal.get() == 6: #
9024  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9025  Vaxis_label = str(round(Vaxis_value, 3))
9026  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
9027  elif Xsignal.get() == 3 or Xsignal.get() == 7:
9028  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
9029  Vaxis_label = str(round(Vaxis_value, 3))
9030  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
9031  elif Xsignal.get() == 2:
9032  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
9033  Iaxis_label = str(round(Iaxis_value, 3))
9034  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
9035  elif Xsignal.get() == 4:
9036  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
9037  Iaxis_label = str(round(Iaxis_value, 3))
9038  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
9039  elif Xsignal.get() == 5:
9040  TempCOLOR = COLORtrace5
9041  if MathTrace.get() == 2:
9042  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9043  elif MathTrace.get() == 3:
9044  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
9045  else:
9046  if MathXAxis == "V-A":
9047  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9048  TempCOLOR = COLORtrace1
9049  elif MathXAxis == "V-B":
9050  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
9051  TempCOLOR = COLORtrace2
9052  elif MathXAxis == "I-A":
9053  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
9054  TempCOLOR = COLORtrace3
9055  elif MathXAxis == "I-B":
9056  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
9057  TempCOLOR = COLORtrace4
9058  else:
9059  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9060  TempCOLOR = COLORtrace5
9061  Vaxis_label = str(round(Vaxis_value, 3))
9062  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
9063  else:
9064  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
9065  if Xsignal.get() == 1 or Xsignal.get() == 6:
9066  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9067  Vaxis_label = str(round(Vaxis_value, 3))
9068  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
9069  elif Xsignal.get() == 3 or Xsignal.get() == 7:
9070  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
9071  Vaxis_label = str(round(Vaxis_value, 3))
9072  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
9073  elif Xsignal.get() == 2:
9074  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
9075  Iaxis_label = str(round(Iaxis_value, 3))
9076  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
9077  elif Xsignal.get() == 4:
9078  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
9079  Iaxis_label = str(round(Iaxis_value, 3))
9080  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
9081  elif Xsignal.get() == 5:
9082  TempCOLOR = COLORtrace5
9083  if MathTrace.get() == 2:
9084  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9085  elif MathTrace.get() == 3:
9086  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
9087  else:
9088  if MathXAxis == "V-A":
9089  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9090  TempCOLOR = COLORtrace1
9091  elif MathXAxis == "V-B":
9092  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
9093  TempCOLOR = COLORtrace2
9094  elif MathXAxis == "I-A":
9095  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
9096  TempCOLOR = COLORtrace3
9097  elif MathXAxis == "I-B":
9098  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
9099  TempCOLOR = COLORtrace4
9100  else:
9101  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9102  Vaxis_label = str(round(Vaxis_value, 3))
9103  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
9104  i = i + 1
9105 # Draw traces
9106 # Avoid writing lines with 1 coordinate
9107  if YsignalVA.get() == 1:
9108  if len(XYlineVA) > 4:
9109  XYca.create_line(XYlineVA, fill=COLORtrace1, width=TRACEwidth.get())
9110  if YsignalIA.get() == 1:
9111  if len(XYlineIA) > 4:
9112  XYca.create_line(XYlineIA, fill=COLORtrace3, width=TRACEwidth.get())
9113  if YsignalVB.get() == 1:
9114  if len(XYlineVB) > 4:
9115  XYca.create_line(XYlineVB, fill=COLORtrace2, width=TRACEwidth.get())
9116  if YsignalIB.get() == 1:
9117  if len(XYlineIB) > 4:
9118  XYca.create_line(XYlineIB, fill=COLORtrace4, width=TRACEwidth.get())
9119  if YsignalM.get() == 1: # or Ysignal.get() == 5:
9120  if len(XYlineM) > 4:
9121  XYca.create_line(XYlineM, fill=COLORtrace5, width=TRACEwidth.get())
9122  if YsignalMX.get() == 1:
9123  if len(XYlineMX) > 4:
9124  XYca.create_line(XYlineMX, fill=COLORtrace6, width=TRACEwidth.get())
9125  if YsignalMY.get() == 1:
9126  if len(XYlineMY) > 4:
9127  XYca.create_line(XYlineMY, fill=COLORtrace7, width=TRACEwidth.get())
9128  if len(XYRlineVA) > 4 and XYRefAV.get() == 1:
9129  XYca.create_line(XYRlineVA, fill=COLORtraceR1, width=TRACEwidth.get())
9130  if len(XYRlineVB) > 4 and XYRefBV.get() == 1:
9131  XYca.create_line(XYRlineVB, fill=COLORtraceR2, width=TRACEwidth.get())
9132  if len(XYRlineIA) > 4 and XYRefAI.get() == 1:
9133  XYca.create_line(XYRlineIA, fill=COLORtraceR3, width=TRACEwidth.get())
9134  if len(XYRlineIB) > 4 and XYRefBI.get() == 1:
9135  XYca.create_line(XYRlineIB, fill=COLORtraceR4, width=TRACEwidth.get())
9136  if len(XYRlineM) > 4 and XYRefM.get() == 1:
9137  XYca.create_line(XYRlineM, fill=COLORtraceR5, width=TRACEwidth.get())
9138  if len(XYRlineMX) > 4 and XYRefMX.get() == 1:
9139  XYca.create_line(XYRlineMX, fill=COLORtraceR6, width=TRACEwidth.get())
9140  if len(XYRlineMY) > 4 and XYRefMY.get() == 1:
9141  XYca.create_line(XYRlineMY, fill=COLORtraceR7, width=TRACEwidth.get())
9142 # Draw Histogram Traces
9143  if Xsignal.get() == 6:
9144  MakeHistogram()
9145  b = 0
9146  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
9147  Xconv1 = float(GRWXY/10.0) / CH1pdvRange
9148  y1 = Y0TXY + GRHXY
9149  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
9150  while b < 4999: #
9151  if HistAsPercent == 1: # convert to percent of total sample count
9152  ylo = float(HBuffA[0][b]) / len(VBuffA)
9153  ylo = ylo * 100.0
9154  else:
9155  ylo = HBuffA[0][b] #
9156  ylo = int(y1 - (Yconv1 * ylo))
9157  if ylo > Ymax:
9158  ylo = Ymax
9159  if ylo < Ymin:
9160  ylo = Ymin
9161  xlo = HBuffA[1][b] - CHAOffset
9162  xlo = int(c2 + Xconv1 * xlo)
9163  Dline = [xlo,y1,xlo,ylo]
9164  XYca.create_line(Dline, fill=COLORtrace1, width=TRACEwidth.get())
9165  b = b + 1
9166  if Xsignal.get() == 7:
9167  MakeHistogram()
9168  b = 0
9169  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
9170  Xconv1 = float(GRWXY/10.0) / CH2pdvRange
9171  y1 = Y0TXY + GRHXY
9172  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
9173  while b < 4999: #
9174  if HistAsPercent == 1: # convert to percent
9175  ylo = float(HBuffB[0][b]) / len(VBuffB)
9176  ylo = ylo * 100.0
9177  else:
9178  ylo = HBuffB[0][b]
9179  ylo = int(y1 - Yconv1 * ylo)
9180  if ylo > Ymax:
9181  ylo = Ymax
9182  if ylo < Ymin:
9183  ylo = Ymin
9184  xlo = HBuffB[1][b] - CHBOffset
9185  xlo = int(c2 + Xconv1 * xlo)
9186  Dline = [xlo,y1,xlo,ylo]
9187  XYca.create_line(Dline, fill=COLORtrace2, width=TRACEwidth.get())
9188  b = b + 1
9189 # Draw X - Y Cursor lines if required
9190  COLORXmarker = COLORtrace1
9191  COLORYmarker = COLORtrace2
9192  Xconv1 = float(GRWXY/10) / CH1pdvRange
9193  Xoffset1 = CHAOffset
9194  X_label = " V"
9195  if Xsignal.get() == 1 or Xsignal.get() == 6:
9196  Xconv1 = float(GRWXY/10) / CH1pdvRange
9197  Xoffset1 = CHAOffset
9198  COLORXmarker = COLORtrace1
9199  X_label = " V"
9200  if Xsignal.get() == 2:
9201  Xconv1 = float(GRWXY/10) / CH1IpdvRange
9202  Xoffset1 = CHAIOffset
9203  COLORXmarker = COLORtrace3
9204  X_label = " mA"
9205  if Xsignal.get() == 3 or Xsignal.get() == 7:
9206  Xconv1 = float(GRWXY/10) / CH2pdvRange
9207  Xoffset1 = CHBOffset
9208  COLORXmarker = COLORtrace2
9209  X_label = " V"
9210  if Xsignal.get() == 4:
9211  Xconv1 = float(GRWXY/10) / CH2IpdvRange
9212  Xoffset1 = CHBIOffset
9213  COLORmarker = COLORtrace4
9214  X_label = " mA"
9215  if Xsignal.get() == 5:
9216  X_label = MathXUnits
9217  if MathXAxis == "V-A":
9218  Xconv1 = float(GRWXY/10) / CH1pdvRange
9219  Xoffset1 = CHAOffset
9220  COLORXmarker = COLORtrace1
9221  elif MathXAxis == "V-B":
9222  Xconv1 = float(GRWXY/10) / CH2pdvRange
9223  Xoffset1 = CHBOffset
9224  COLORXmarker = COLORtrace2
9225  elif MathXAxis == "I-A":
9226  Xconv1 = float(GRWXY/10) / CH1IpdvRange
9227  Xoffset1 = CHAIOffset
9228  COLORXmarker = COLORtrace3
9229  elif MathXAxis == "I-B":
9230  Xconv1 = float(GRWXY/10) / CH2IpdvRange
9231  Xoffset1 = CHBIOffset
9232  COLORXmarker = COLORtrace4
9233  else:
9234  Xconv1 = float(GRWXY/10) / CH1pdvRange
9235  Xoffset1 = CHAOffset
9236  COLORXmarker = COLORtrace1
9237 # Set variables just incase
9238  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
9239  Yoffset1 = CHAOffset
9240  Y_label = " V"
9241  if YsignalVA.get() == 1 or YsignalM.get() == 1:
9242  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
9243  Yoffset1 = CHAOffset
9244  COLORYmarker = COLORtrace1
9245  Y_label = " V"
9246  if YsignalIA.get() == 1:
9247  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
9248  Yoffset1 = CHAIOffset
9249  COLORYmarker = COLORtrace3
9250  Y_label = " mA"
9251  if YsignalVB.get() == 1 or YsignalM.get() == 1:
9252  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
9253  Yoffset1 = CHBOffset
9254  COLORYmarker = COLORtrace2
9255  Y_label = " V"
9256  if YsignalIB.get() == 1:
9257  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
9258  Yoffset1 = CHBIOffset
9259  COLORYmarker = COLORtrace4
9260  Y_label = " mA"
9261  if YsignalM.get() == 1 or YsignalMX.get() == 1 or YsignalMY.get() == 1:
9262  Y_label = MathYUnits
9263  if MathYAxis == "V-A":
9264  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
9265  Yoffset1 = CHAOffset
9266  COLORYmarker = COLORtrace1
9267  elif MathYAxis == "V-B":
9268  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
9269  Yoffset1 = CHBOffset
9270  COLORYmarker = COLORtrace2
9271  elif MathYAxis == "I-A":
9272  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
9273  Yoffset1 = CHAIOffset
9274  COLORYmarker = COLORtrace3
9275  elif MathYAxis == "I-B":
9276  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
9277  Yoffset1 = CHBIOffset
9278  COLORYmarker = COLORtrace4
9279  else:
9280  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
9281  Yoffset1 = CHAOffset
9282  COLORYmarker = COLORtrace1
9283  if ShowXCur.get() > 0:
9284  Dline = [XCursor, Y0TXY, XCursor, Y0TXY+GRHXY]
9285  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
9286  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
9287  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
9288  XString = ' {0:.3f} '.format(xvolts)
9289  V_label = XString + X_label
9290  XYca.create_text(XCursor+1, YCursor-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
9291  if ShowYCur.get() > 0:
9292  Dline = [X0LXY, YCursor, X0LXY+GRWXY, YCursor]
9293  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
9294  c1 = GRHXY / 2.0 + Y0TXY # fixed Y correction
9295  yvolts = ((YCursor-c1)/Yconv1) - Yoffset1
9296  V1String = ' {0:.3f} '.format(-yvolts)
9297  V_label = V1String + Y_label
9298  XYca.create_text(XCursor+1, YCursor+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
9299  if ShowXCur.get() == 0 and ShowYCur.get() == 0 and MouseWidget == XYca:
9300  if MouseX > X0LXY and MouseX < X0LXY+GRWXY and MouseY > Y0TXY and MouseY < Y0TXY+GRHXY:
9301  Dline = [MouseX, Y0TXY, MouseX, Y0TXY+GRHXY]
9302  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
9303  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
9304  xvolts = Xoffset1 - ((c1-MouseX)/Xconv1) # XCursor
9305  XString = ' {0:.3f} '.format(xvolts)
9306  V_label = XString + X_label
9307  XYca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
9308  Dline = [X0LXY, MouseY, X0LXY+GRWXY, MouseY]
9309  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
9310  c1 = GRHXY / 2 + Y0TXY # fixed Y correction
9311  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
9312  V1String = ' {0:.3f} '.format(-yvolts)
9313  V_label = V1String + Y_label
9314  XYca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
9315 #
9316 # General information on top of the grid
9317 # Sweep information
9318  sttxt = "Running"
9319  if TRACEmodeTime.get() == 1:
9320  sttxt = sttxt + " Averaging"
9321  if ManualTrigger.get() == 1:
9322  sttxt = "Manual Trigger"
9323  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
9324  sttxt = "Stopped"
9325  if ScreenXYrefresh.get() == 1:
9326  sttxt = sttxt + " Persistance ON"
9327  # Delete text at bottom of screen
9328  de = XYca.find_enclosed( X0LXY-1, Y0TXY+GRHXY+19, CANVASwidthXY, Y0TXY+GRHXY+100)
9329  for n in de:
9330  XYca.delete(n)
9331  # Delete text at top of screen
9332  de = XYca.find_enclosed( X0LXY-1, -1, CANVASwidthXY, 20)
9333  for n in de:
9334  XYca.delete(n)
9335  if LabelPlotText.get() > 0:
9336  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
9337  else:
9338  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
9339  x = X0LXY
9340  y = 12
9341  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
9342  # digital I/O indicators
9343  x2 = X0LXY + GRWXY
9344  BoxColor = "#808080" # gray
9345  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 1 :
9346  if D0.get() == 0 and D4.get() == 0:
9347  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
9348  if Dval[0] == 1:
9349  BoxColor = "#00ff00" # 100% green
9350  elif Dval[0] == 0:
9351  BoxColor = "#ff0000" # 100% red
9352  XYca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
9353  else:
9354  XYca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
9355  if D1.get() == 0 and D5.get() == 0:
9356  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
9357  if Dval[0] == 1:
9358  BoxColor = "#00ff00" # 100% green
9359  elif Dval[0] == 0:
9360  BoxColor = "#ff0000" # 100% red
9361  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
9362  else:
9363  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
9364  if D2.get() == 0 and D6.get() == 0:
9365  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
9366  if Dval[0] == 1:
9367  BoxColor = "#00ff00" # 100% green
9368  elif Dval[0] == 0:
9369  BoxColor = "#ff0000" # 100% red
9370  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
9371  else:
9372  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
9373  if D3.get() == 0 and D7.get() == 0:
9374  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
9375  if Dval[0] == 1:
9376  BoxColor = "#00ff00" # 100% green
9377  elif Dval[0] == 0:
9378  BoxColor = "#ff0000" # 100% red
9379  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
9380  else:
9381  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
9382  XYca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext, font=("arial", FontSize ))
9383  # print period and frequency of displayed channels
9384  txt = " "
9385  if Xsignal.get() == 1 or Xsignal.get() == 3:
9386  FindRisingEdge(VBuffA, VBuffB)
9387  if Xsignal.get() == 1:
9388  if MeasAHW.get() == 1:
9389  txt = txt + " CA Hi Width = " + ' {0:.2f} '.format(CHAHW) + " mS "
9390  if MeasALW.get() == 1:
9391  txt = txt + " CA Lo Width = " + ' {0:.2f} '.format(CHALW) + " mS "
9392  if MeasADCy.get() == 1:
9393  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
9394  if MeasAPER.get() == 1:
9395  txt = txt + " CA Period = " + ' {0:.2f} '.format(CHAperiod) + " mS "
9396  if MeasAFREQ.get() == 1:
9397  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
9398  if Xsignal.get() == 3:
9399  if MeasBHW.get() == 1:
9400  txt = txt + " CB Hi Width = " + ' {0:.2f} '.format(CHBHW) + " mS "
9401  if MeasBLW.get() == 1:
9402  txt = txt + " CB Lo Width = " + ' {0:.2f} '.format(CHBLW) + " mS "
9403  if MeasBDCy.get() == 1:
9404  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
9405  if MeasBPER.get() == 1:
9406  txt = txt + " CB Period = " + ' {0:.2f} '.format(CHBperiod) + " mS "
9407  if MeasBFREQ.get() == 1:
9408  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
9409  if MeasPhase.get() == 1:
9410  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
9411 
9412  x = X0LXY
9413  y = Y0TXY+GRHXY+int(2.5*FontSize) # 20
9414  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
9415  txt = " "
9416  if Xsignal.get() == 1 or YsignalVA.get() == 1 or Xsignal.get() == 6:
9417  # Channel A information
9418  txt = "CHA: "
9419  txt = txt + str(CH1pdvRange) + " V/div"
9420  if MeasDCV1.get() == 1:
9421  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
9422  if MeasMaxV1.get() == 1:
9423  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
9424  if MeasTopV1.get() == 1:
9425  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
9426  if MeasMinV1.get() == 1:
9427  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
9428  if MeasBaseV1.get() == 1:
9429  txt = txt + " Top = " + ' {0:.4f} '.format(VABase)
9430  if MeasMidV1.get() == 1:
9431  MidV1 = (MaxV1+MinV1)/2
9432  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
9433  if MeasPPV1.get() == 1:
9434  PPV1 = MaxV1-MinV1
9435  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
9436  if MeasRMSV1.get() == 1:
9437  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
9438  if MeasUserA.get() == 1:
9439  try:
9440  TempValue = eval(UserAString)
9441  V1String = ' {0:.4f} '.format(TempValue)
9442  except:
9443  V1String = "####"
9444  txt = txt + UserALabel + " = " + V1String
9445  if Xsignal.get() == 2:
9446  txt = "CHA: "
9447  txt = txt + str(CH1IpdvRange) + " mA/div"
9448  elif (Xsignal.get() == 2):
9449  txt = txt + "CHA: "
9450  txt = txt + str(CH1IpdvRange) + " mA/div"
9451  if Xsignal.get() == 2 or YsignalIA.get() == 1:
9452  if MeasDCI1.get() == 1:
9453  V1String = ' {0:.2f} '.format(DCI1)
9454  txt = txt + " AvgI = " + V1String
9455  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
9456  try:
9457  Resvalue = (DCV1/DCI1)*1000
9458  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
9459  except:
9460  txt = txt + " Res = OverRange"
9461  if MeasMaxI1.get() == 1:
9462  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
9463  if MeasMinI1.get() == 1:
9464  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
9465  if MeasMidI1.get() == 1:
9466  MidI1 = (MaxI1+MinI1)/2
9467  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
9468  if MeasPPI1.get() == 1:
9469  PPI1 = MaxI1-MinI1
9470  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
9471  if MeasRMSI1.get() == 1:
9472  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
9473 
9474  x = X0LXY
9475  y = Y0TXY+GRHXY+int(4*FontSize) # 32
9476  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
9477  txt= " "
9478  # Channel B information
9479  if Xsignal.get() == 3 or YsignalVB.get() == 1 or Xsignal.get() == 7:
9480  txt = "CHB: "
9481  txt = txt + str(CH2pdvRange) + " V/div"
9482  if MeasDCV2.get() == 1:
9483  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
9484  if MeasMaxV2.get() == 1:
9485  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
9486  if MeasTopV2.get() == 1:
9487  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
9488  if MeasMinV2.get() == 1:
9489  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
9490  if MeasBaseV2.get() == 1:
9491  txt = txt + " Top = " + ' {0:.4f} '.format(VBBase)
9492  if MeasMidV2.get() == 1:
9493  MidV2 = (MaxV2+MinV2)/2
9494  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
9495  if MeasPPV2.get() == 1:
9496  PPV2 = MaxV2-MinV2
9497  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
9498  if MeasRMSV2.get() == 1:
9499  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
9500  if MeasUserB.get() == 1:
9501  try:
9502  TempValue = eval(UserBString)
9503  V1String = ' {0:.4f} '.format(TempValue)
9504  except:
9505  V1String = "####"
9506  txt = txt + UserBLabel + " = " + V1String
9507  if Xsignal.get() == 4:
9508  txt = "CHB: "
9509  txt = txt + str(CH2IpdvRange) + " mA/div"
9510  elif Xsignal.get() == 4:
9511  txt = txt + "CHB: "
9512  txt = txt + str(CH2IpdvRange) + " mA/div"
9513  if Xsignal.get() == 4 or YsignalIB.get() == 1:
9514  if MeasDCI2.get() == 1:
9515  V1String = ' {0:.2f} '.format(DCI2)
9516  txt = txt + " AvgI = " + V1String
9517  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
9518  try:
9519  Resvalue = (DCV2/DCI2)*1000
9520  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
9521  except:
9522  txt = txt + " Res = OverRange"
9523  if MeasMaxI2.get() == 1:
9524  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
9525  if MeasMinI2.get() == 1:
9526  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
9527  if MeasMidI2.get() == 1:
9528  MidI2 = (MaxI2+MinI2)/2
9529  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
9530  if MeasPPI2.get() == 1:
9531  PPI2 = MaxI2-MinI2
9532  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
9533  if MeasRMSI2.get() == 1:
9534  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
9535 
9536  x = X0LXY
9537  y = Y0TXY+GRHXY+int(5.5 * FontSize) # 44
9538  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
9539 #
9540 def SetScaleA():
9541  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9542 
9543  if MarkerScale.get() != 1:
9544  MarkerScale.set(1)
9545  CHAlab.config(style="Rtrace1.TButton")
9546  CHBlab.config(style="Strace2.TButton")
9547  CHAIlab.config(style="Strace3.TButton")
9548  CHBIlab.config(style="Strace4.TButton")
9549  else:
9550  MarkerScale.set(0)
9551 #
9552 def SetScaleIA():
9553  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9554 
9555  if MarkerScale.get() != 3:
9556  MarkerScale.set(3)
9557  CHAlab.config(style="Strace1.TButton")
9558  CHBlab.config(style="Strace2.TButton")
9559  CHAIlab.config(style="Rtrace3.TButton")
9560  CHBIlab.config(style="Strace4.TButton")
9561  else:
9562  MarkerScale.set(0)
9563 
9564 def SetScaleB():
9565  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9566 
9567  if MarkerScale.get() != 2:
9568  MarkerScale.set(2)
9569  CHAlab.config(style="Strace1.TButton")
9570  CHBlab.config(style="Rtrace2.TButton")
9571  CHAIlab.config(style="Strace3.TButton")
9572  CHBIlab.config(style="Strace4.TButton")
9573  else:
9574  MarkerScale.set(0)
9575 
9576 def SetScaleIB():
9577  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9578 
9579  if MarkerScale.get() != 3:
9580  MarkerScale.set(4)
9581  CHAlab.config(style="Strace1.TButton")
9582  CHBlab.config(style="Strace2.TButton")
9583  CHAIlab.config(style="Strace3.TButton")
9584  CHBIlab.config(style="Rtrace4.TButton")
9585  else:
9586  MarkerScale.set(0)
9587 #
9588 def SetXYScaleA():
9589  global MarkerXYScale, CHAxylab, CHBxylab
9590 
9591  MarkerXYScale.set(1)
9592  CHAxylab.config(style="Rtrace1.TButton")
9593  CHBxylab.config(style="Strace2.TButton")
9594 
9595 def SetXYScaleB():
9596  global MarkerXYScale, CHAxylab, CHBxylab
9597 
9598  MarkerXYScale.set(2)
9599  CHBxylab.config(style="Rtrace2.TButton")
9600  CHAxylab.config(style="Strace1.TButton")
9601 #
9602 def onCanvasClickRight(event):
9603  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
9604 
9605  TCursor = event.x
9606  VCursor = event.y
9607  if RUNstatus.get() == 0:
9609  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
9610 
9611 def onCanvasClickScroll(event):
9612  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca, MWcount
9613  global MeasGateStatus, MeasGateLeft, MeasGateRight, TIMEdiv, GRW
9614 
9615  ShiftKeyDwn = event.state & 1
9616  if event.widget == ca:
9617  if ShowTCur.get() > 0 or ShowVCur.get() > 0: # move cursors if shown
9618  if ShowTCur.get() > 0 and ShiftKeyDwn == 0:
9619  # respond to Linux or Windows wheel event
9620  if event.num == 5 or event.delta == -120:
9621  TCursor -= 1
9622  if event.num == 4 or event.delta == 120:
9623  TCursor += 1
9624  elif ShowVCur.get() > 0 or ShiftKeyDwn == 1:
9625  # respond to Linux or Windows wheel event
9626  if event.num == 5 or event.delta == -120:
9627  VCursor += 1
9628  if event.num == 4 or event.delta == 120:
9629  VCursor -= 1
9630 
9634  else:
9635  if MeasGateStatus.get() == 1:
9636  Tstep = (TIMEdiv / GRW) / 10 # time in mS per pixel
9637  if ShiftKeyDwn == 0:
9638  if event.num == 5 or event.delta == -120:
9639  MeasGateLeft = MeasGateLeft + (-100 * Tstep)
9640  if event.num == 4 or event.delta == 120:
9641  MeasGateLeft = MeasGateLeft + (100 * Tstep)
9642  # MeasGateLeft = MeasGateLeft + (event.delta * Tstep) #+ HoldOff
9643  if ShiftKeyDwn == 1:
9644  if event.num == 5 or event.delta == -120:
9645  MeasGateRight = MeasGateRight + (-100 * Tstep)
9646  if event.num == 4 or event.delta == 120:
9647  MeasGateRight = MeasGateRight + (100 * Tstep)
9648  #MeasGateRight = MeasGateRight + (event.delta * Tstep) #+ HoldOff
9649  try:
9650  onSpinBoxScroll(event) # if cursor are not showing scroll the Horx time base
9651  except:
9652  donothing()
9653  if RUNstatus.get() == 0:
9655 
9656 def onCanvasUpArrow(event):
9657  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca, Bodeca
9658 
9659  shift_key = event.state & 1
9660  if event.widget == ca:
9661  if ShowVCur.get() > 0 and shift_key == 0:
9662  VCursor = VCursor - 1
9663  elif ShowVCur.get() > 0 and shift_key == 1:
9664  VCursor = VCursor - 5
9665  if RUNstatus.get() == 0:
9667  try:
9668  if event.widget == XYca:
9669  if ShowYCur.get() > 0 and shift_key == 0:
9670  YCursor = YCursor - 1
9671  elif ShowYCur.get() > 0 and shift_key == 1:
9672  YCursor = YCursor - 5
9673  if RUNstatus.get() == 0:
9674  UpdateXYScreen()
9675  except:
9676  donothing()
9677  try:
9678  if event.widget == Freqca:
9679  if ShowdBCur.get() > 0 and shift_key == 0:
9680  dBCursor = dBCursor - 1
9681  elif ShowdBCur.get() > 0 and shift_key == 1:
9682  dBCursor = dBCursor - 5
9683  if RUNstatus.get() == 0:
9685  except:
9686  donothing()
9687  try:
9688  if event.widget == Bodeca:
9689  if ShowBdBCur.get() > 0 and shift_key == 0:
9690  BdBCursor = BdBCursor - 1
9691  elif ShowBdBCur.get() > 0 and shift_key == 1:
9692  BdBCursor = BdBCursor - 5
9693  if RUNstatus.get() == 0:
9695  except:
9696  donothing()
9697 
9698 def onCanvasDownArrow(event):
9699  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca
9700 
9701  shift_key = event.state & 1
9702  if event.widget == ca:
9703  if ShowVCur.get() > 0 and shift_key == 0:
9704  VCursor = VCursor + 1
9705  elif ShowVCur.get() > 0 and shift_key == 1:
9706  VCursor = VCursor + 5
9707  if RUNstatus.get() == 0:
9709  try:
9710  if event.widget == XYca:
9711  if ShowYCur.get() > 0 and shift_key == 0:
9712  YCursor = YCursor + 1
9713  elif ShowYCur.get() > 0 and shift_key == 1:
9714  YCursor = YCursor + 5
9715  if RUNstatus.get() == 0:
9716  UpdateXYScreen()
9717  except:
9718  donothing()
9719  try:
9720  if event.widget == Freqca:
9721  if ShowdBCur.get() > 0 and shift_key == 0:
9722  dBCursor = dBCursor + 1
9723  elif ShowdBCur.get() > 0 and shift_key == 1:
9724  dBCursor = dBCursor + 5
9725  if RUNstatus.get() == 0:
9727  except:
9728  donothing()
9729  try:
9730  if event.widget == Bodeca:
9731  if ShowBdBCur.get() > 0 and shift_key == 0:
9732  BdBCursor = BdBCursor + 1
9733  elif ShowBdBCur.get() > 0 and shift_key == 1:
9734  BdBCursor = BdBCursor + 5
9735  if RUNstatus.get() == 0:
9737  except:
9738  donothing()
9739 
9740 def onCanvasLeftArrow(event):
9741  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9742 
9743  shift_key = event.state & 1
9744  if event.widget == ca:
9745  if ShowTCur.get() > 0 and shift_key == 0:
9746  TCursor = TCursor - 1
9747  elif ShowTCur.get() > 0 and shift_key == 1:
9748  TCursor = TCursor - 5
9749  if RUNstatus.get() == 0:
9751  try:
9752  if event.widget == XYca:
9753  if ShowXCur.get() > 0 and shift_key == 0:
9754  XCursor = XCursor - 1
9755  elif ShowXCur.get() > 0 and shift_key == 1:
9756  XCursor = XCursor - 5
9757  if RUNstatus.get() == 0:
9758  UpdateXYScreen()
9759  except:
9760  donothing()
9761  try:
9762  if event.widget == Freqca:
9763  if ShowFCur.get() > 0 and shift_key == 0:
9764  FCursor = FCursor - 1
9765  elif ShowFCur.get() > 0 and shift_key == 1:
9766  FCursor = FCursor - 5
9767  if RUNstatus.get() == 0:
9769  except:
9770  donothing()
9771  try:
9772  if event.widget == Bodeca:
9773  if ShowBPCur.get() > 0 and shift_key == 0:
9774  BPCursor = BPCursor - 1
9775  elif ShowBPCur.get() > 0 and shift_key == 1:
9776  BPCursor = BPCursor - 5
9777  if RUNstatus.get() == 0:
9779  except:
9780  donothing()
9781 
9782 def onCanvasRightArrow(event):
9783  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9784 
9785  shift_key = event.state & 1
9786  if event.widget == ca:
9787  if ShowTCur.get() > 0 and shift_key == 0:
9788  TCursor = TCursor + 1
9789  elif ShowTCur.get() > 0 and shift_key == 1:
9790  TCursor = TCursor + 5
9791  if RUNstatus.get() == 0:
9793  try:
9794  if event.widget == XYca:
9795  if ShowXCur.get() > 0 and shift_key == 0:
9796  XCursor = XCursor + 1
9797  elif ShowXCur.get() > 0 and shift_key == 1:
9798  XCursor = XCursor + 5
9799  if RUNstatus.get() == 0:
9800  UpdateXYScreen()
9801  except:
9802  donothing()
9803  try:
9804  if event.widget == Freqca:
9805  if ShowFCur.get() > 0 and shift_key == 0:
9806  FCursor = FCursor + 1
9807  elif ShowFCur.get() > 0 and shift_key == 1:
9808  FCursor = FCursor + 5
9809  if RUNstatus.get() == 0:
9811  except:
9812  donothing()
9813  try:
9814  if event.widget == Bodeca:
9815  if ShowBPCur.get() > 0 and shift_key == 0:
9816  BPCursor = BPCursor + 1
9817  elif ShowBPCur.get() > 0 and shift_key == 1:
9818  BPCursor = BPCursor + 5
9819  if RUNstatus.get() == 0:
9821  except:
9822  donothing()
9823 
9824 def onCanvasSpaceBar(event):
9825  global RUNstatus, ca, XYca, Freqca, Bodeca, IAca
9826 
9827  if event.widget == ca:
9828  if RUNstatus.get() == 0:
9829  BStart()
9830  elif RUNstatus.get() > 0:
9831  BStop()
9832  try:
9833  if event.widget == XYca:
9834  if RUNstatus.get() == 0:
9835  BStart()
9836  elif RUNstatus.get() > 0:
9837  BStop()
9838  except:
9839  donothing()
9840  try:
9841  if event.widget == IAca:
9842  if RUNstatus.get() == 0:
9843  BStart()
9844  elif RUNstatus.get() > 0:
9845  BStop()
9846  except:
9847  donothing()
9848  try:
9849  if event.widget == Freqca:
9850  if RUNstatus.get() == 0:
9851  BStartSA()
9852  elif RUNstatus.get() > 0:
9853  BStopSA()
9854  except:
9855  donothing()
9856  try:
9857  if event.widget == Bodeca:
9858  if RUNstatus.get() == 0:
9859  BStartBP()
9860  elif RUNstatus.get() > 0:
9861  BStopBP()
9862  except:
9863  donothing()
9864 #
9865 def onCanvasClickLeft(event):
9866  global X0L # Left top X value
9867  global Y0T # Left top Y value
9868  global GRW # Screenwidth
9869  global GRH # Screenheight
9870  global FontSize
9871  global ca, MarkerLoc, Mulx, Roll_Mode
9872  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
9873  global TMsb, CHAsb, CHBsb, CHAIsb, CHBIsb, MarkerScale
9874  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
9875  global SAMPLErate, RUNstatus, MarkerNum, PrevV, PrevT
9876  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
9877  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
9878  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
9879  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
9880  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
9881  global MeasGateLeft, MeasGateRight, MeasGateStatus, MeasGateNum, TMsb, SAMPLErate
9882 
9883  try:
9884  HoldOff = float(eval(HoldOffentry.get()))
9885  if HoldOff < 0:
9886  HoldOff = 0
9887  except:
9888  HoldOffentry.delete(0,END)
9889  HoldOffentry.insert(0, HoldOff)
9890  # get time scale
9891  try:
9892  TIMEdiv = float(eval(TMsb.get()))
9893  except:
9894  TIMEdiv = 0.5
9895  TMsb.delete(0,"end")
9896  TMsb.insert(0,TIMEdiv)
9897  # prevent divide by zero error
9898  if TIMEdiv < 0.0002:
9899  TIMEdiv = 0.01
9900  # add markers only if stopped
9901  if (RUNstatus.get() == 0):
9902  MarkerNum = MarkerNum + 1
9903  # get the vertical ranges
9904  try:
9905  CH1pdvRange = float(eval(CHAsb.get()))
9906  except:
9907  CHAsb.delete(0,END)
9908  CHAsb.insert(0, CH1pdvRange)
9909  try:
9910  CH2pdvRange = float(eval(CHBsb.get()))
9911  except:
9912  CHBsb.delete(0,END)
9913  CHBsb.insert(0, CH2pdvRange)
9914  try:
9915  CH1IpdvRange = float(eval(CHAIsb.get()))
9916  except:
9917  CHAIsb.delete(0,END)
9918  CHAIsb.insert(0, CH1IpdvRange)
9919  try:
9920  CH2IpdvRange = float(eval(CHBIsb.get()))
9921  except:
9922  CHBIsb.delete(0,END)
9923  CHBIsb.insert(0, CH2IpdvRange)
9924  # get the vertical offsets
9925  try:
9926  CHAOffset = float(eval(CHAVPosEntry.get()))
9927  except:
9928  CHAVPosEntry.delete(0,END)
9929  CHAVPosEntry.insert(0, CHAOffset)
9930  try:
9931  CHAIOffset = float(eval(CHAIPosEntry.get()))
9932  except:
9933  CHAIPosEntry.delete(0,END)
9934  CHAIPosEntry.insert(0, CHAIOffset)
9935  try:
9936  CHBOffset = float(eval(CHBVPosEntry.get()))
9937  except:
9938  CHBVPosEntry.delete(0,END)
9939  CHBVPosEntry.insert(0, CHBOffset)
9940  try:
9941  CHBIOffset = float(eval(CHBIPosEntry.get()))
9942  except:
9943  CHBIPosEntry.delete(0,END)
9944  CHBIPosEntry.insert(0, CHBIOffset)
9945  # prevent divide by zero error
9946  if CH1pdvRange < 0.001:
9947  CH1pdvRange = 0.001
9948  if CH2pdvRange < 0.001:
9949  CH2pdvRange = 0.001
9950  if CH1IpdvRange < 1.0:
9951  CH1IpdvRange = 1.0
9952  if CH2IpdvRange < 1.0:
9953  CH2IpdvRange = 1.0
9954 #
9955  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
9956  try:
9957  CHMApdvRange = float(eval(CHB_Asb.get()))
9958  except:
9959  CHB_Asb.delete(0,END)
9960  CHB_Asb.insert(0, CHMApdvRange)
9961  try:
9962  CHMBpdvRange = float(eval(CHB_Bsb.get()))
9963  except:
9964  CHB_Bsb.delete(0,END)
9965  CHB_Bsb.insert(0, CHMBpdvRange)
9966  try:
9967  CHMCpdvRange = float(eval(CHB_Csb.get()))
9968  except:
9969  CHB_Csb.delete(0,END)
9970  CHB_Csb.insert(0, CHMCpdvRange)
9971  try:
9972  CHMDpdvRange = float(eval(CHB_Dsb.get()))
9973  except:
9974  CHB_Dsb.delete(0,END)
9975  CHB_Dsb.insert(0, CHMDpdvRange)
9976  YconvMA = float(GRH/10.0) / CHMApdvRange
9977  YconvMB = float(GRH/10.0) / CHMBpdvRange
9978  YconvMC = float(GRH/10.0) / CHMCpdvRange
9979  YconvMD = float(GRH/10.0) / CHMDpdvRange
9980  try:
9981  CHBAOffset = float(eval(CHB_APosEntry.get()))
9982  except:
9983  CHB_APosEntry.delete(0,END)
9984  CHB_APosEntry.insert(0, CHBAOffset)
9985  try:
9986  CHBBOffset = float(eval(CHB_BPosEntry.get()))
9987  except:
9988  CHB_BPosEntry.delete(0,END)
9989  CHB_BPosEntry.insert(0, CHBBOffset)
9990  try:
9991  CHBCOffset = float(eval(CHB_CPosEntry.get()))
9992  except:
9993  CHB_CPosEntry.delete(0,END)
9994  CHB_CPosEntry.insert(0, CHBCOffset)
9995  try:
9996  CHBDOffset = float(eval(CHB_DPosEntry.get()))
9997  except:
9998  CHB_DPosEntry.delete(0,END)
9999  CHB_DPosEntry.insert(0, CHBDOffset)
10000  Yoffset1 = CHAOffset
10001  if MarkerScale.get() == 1:
10002  Yconv1 = float(GRH/10.0) / CH1pdvRange
10003  Yoffset1 = CHAOffset
10004  COLORmarker = COLORtrace1
10005  Units = " V"
10006  elif MarkerScale.get() == 2:
10007  Yconv1 = float(GRH/10.0) / CH2pdvRange
10008  Yoffset1 = CHBOffset
10009  COLORmarker = COLORtrace2
10010  Units = " V"
10011  elif MarkerScale.get() == 3:
10012  Yconv1 = float(GRH/10.0) / CH1IpdvRange
10013  Yoffset1 = CHAIOffset
10014  COLORmarker = COLORtrace3
10015  Units = " mA"
10016  elif MarkerScale.get() == 4:
10017  Yconv1 = float(GRH/10.0) / CH2IpdvRange
10018  Yoffset1 = CHBIOffset
10019  COLORmarker = COLORtrace4
10020  Units = " mA"
10021  # Aanalog Mux settings
10022  elif MarkerScale.get() == 5:
10023  Yconv1 = float(GRH/10.0) / CHMApdvRange
10024  Yoffset1 = CHBAOffset
10025  COLORmarker = COLORtrace2
10026  Units = " V"
10027  elif MarkerScale.get() == 6:
10028  Yconv1 = float(GRH/10.0) / CHMBpdvRange
10029  Yoffset1 = CHBBOffset
10030  COLORmarker = COLORtrace6
10031  Units = " V"
10032  elif MarkerScale.get() == 7:
10033  Yconv1 = float(GRH/10.0) / CHMCpdvRange
10034  Yoffset1 = CHBCOffset
10035  COLORmarker = COLORtrace7
10036  Units = " V"
10037  elif MarkerScale.get() == 8:
10038  Yconv1 = float(GRH/10.0) / CHMDpdvRange
10039  Yoffset1 = CHBDOffset
10040  COLORmarker = COLORtrace4
10041  Units = " V"
10042  else:
10043  Yconv1 = float(GRH/10.0) / CH1pdvRange
10044  Yoffset1 = CHAOffset
10045  COLORmarker = COLORtrace1
10046  Units = " V"
10047  #
10048  c1 = GRH / 2.0 + Y0T # fixed correction channel A
10049  xc1 = GRW / 2.0 + X0L
10050  c2 = GRH / 2.0 + Y0T # fixed correction channel B
10051  # draw X at marker point and number
10052  ca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
10053  ca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
10054  # DISsamples = (10.0 * TIMEdiv) # grid width in time
10055  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
10056  Tpoint = ((event.x-X0L) * Tstep) + HoldOff
10057  #
10058  Tpoint = Tpoint/Mulx
10059  if Tpoint >= 1000:
10060  axis_value = Tpoint / 1000.0
10061  TString = ' {0:.2f} '.format(axis_value) + " S "
10062  if Tpoint < 1000 and Tpoint >= 1:
10063  axis_value = Tpoint
10064  TString = ' {0:.2f} '.format(axis_value) + " mS "
10065  if Tpoint < 1:
10066  axis_value = Tpoint * 1000.0
10067  TString = ' {0:.2f} '.format(axis_value) + " uS "
10068  # TString = ' {0:.2f} '.format(Tpoint)
10069  yvolts = ((event.y-c1)/Yconv1) - Yoffset1
10070  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
10071  V1String = ' {0:.3f} '.format(-yvolts)
10072  else:
10073  V1String = ' {0:.1f} '.format(-yvolts)
10074  V_label = str(MarkerNum) + " " + TString + V1String
10075  V_label = V_label + Units
10076  if MarkerNum > 1:
10077  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
10078  DeltaV = ' {0:.3f} '.format(PrevV-yvolts)
10079  else:
10080  DeltaV = ' {0:.1f} '.format(PrevV-yvolts)
10081  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
10082  DT = (Tpoint-PrevT)
10083  if Tpoint >= 1000:
10084  axis_value = DT / 1000.0
10085  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
10086  if Tpoint < 1000 and Tpoint >= 1:
10087  axis_value = DT
10088  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
10089  if Tpoint < 1:
10090  axis_value = DT * 1000.0
10091  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
10092  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
10093  DFreq = ' {0:.3f} '.format(1.0/(Tpoint-PrevT))
10094  V_label = V_label + " Delta " + DeltaT + DeltaV
10095  V_label = V_label + Units
10096  V_label = V_label + ", Freq " + DFreq + " KHz"
10097  else:
10098  V_label = V_label + " Delta " + DeltaV + Units
10099  # place in upper left unless specified otherwise
10100  TxScale = FontSize + 2
10101  x = X0L + 5
10102  y = Y0T + 3 + (MarkerNum*TxScale)
10103  Justify = 'w'
10104  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
10105  x = X0L + GRW - 5
10106  y = Y0T + 3 + (MarkerNum*TxScale)
10107  Justify = 'e'
10108  if MarkerLoc == 'LL' or MarkerLoc == 'll':
10109  x = X0L + 5
10110  y = Y0T + GRH + 3 - (MarkerNum*TxScale)
10111  Justify = 'w'
10112  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
10113  x = X0L + GRW - 5
10114  y = Y0T + GRH + 3 - (MarkerNum*TxScale)
10115  Justify = 'e'
10116  ca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor=Justify, font=("arial", FontSize ))
10117  ca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
10118  PrevV = yvolts
10119  PrevT = Tpoint
10120  else:
10121  if MeasGateStatus.get() == 1:
10122  #DISsamples = (10.0 * TIMEdiv) # grid width in time
10123  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
10124  if MeasGateNum == 0:
10125  MeasGateLeft = ((event.x-X0L) * Tstep) #+ HoldOff
10126  MeasGateNum = 1
10127  else:
10128  MeasGateRight = ((event.x-X0L) * Tstep) #+ HoldOff
10129  MeasGateNum = 0
10130  LeftGate = X0L + MeasGateLeft / Tstep
10131  RightGate = X0L + MeasGateRight / Tstep
10132  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, fill=COLORtext)
10133  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, fill=COLORtext)
10134 
10135 #
10136 def onCanvasOne(event):
10137  global ShowC1_V
10138 
10139  if ShowC1_V.get() == 0:
10140  ShowC1_V.set(1)
10141  else:
10142  ShowC1_V.set(0)
10143 #
10144 def onCanvasTwo(event):
10145  global ShowC2_V
10146 
10147  if ShowC2_V.get() == 0:
10148  ShowC2_V.set(1)
10149  else:
10150  ShowC2_V.set(0)
10151 #
10152 def onCanvasThree(event):
10153  global ShowC1_I
10154 
10155  if ShowC1_I.get() == 0:
10156  ShowC1_I.set(1)
10157  else:
10158  ShowC1_I.set(0)
10159 #
10160 def onCanvasFour(event):
10161  global ShowC2_I
10162 
10163  if ShowC2_I.get() == 0:
10164  ShowC2_I.set(1)
10165  else:
10166  ShowC2_I.set(0)
10167 #
10168 def onCanvasFive(event):
10169  global MathTrace
10170 
10171  MathTrace.set(1)
10172 #
10173 def onCanvasSix(event):
10174  global MathTrace
10175 
10176  MathTrace.set(2)
10177 #
10178 def onCanvasSeven(event):
10179  global MathTrace
10180 
10181  MathTrace.set(3)
10182 #
10183 def onCanvasEight(event):
10184  global MathTrace
10185 
10186  MathTrace.set(10)
10187 #
10188 def onCanvasNine(event):
10189  global MathTrace
10190 
10191  MathTrace.set(12)
10192 #
10193 def onCanvasZero(event):
10194  global MathTrace
10195 
10196  MathTrace.set(0)
10197 #
10198 def onCanvasTrising(event):
10199  global TgEdge
10200 
10201  TgEdge.set(0)
10202 #
10203 def onCanvasTfalling(event):
10204  global TgEdge
10205 
10206  TgEdge.set(1)
10207 #
10208 def onCanvasSnap(event):
10209 
10210  BSnapShot()
10211 #
10212 def onCanvasAverage(event):
10213  global TRACEmodeTime
10214 
10215  if TRACEmodeTime.get() == 0:
10216  TRACEmodeTime.set(1)
10217  else:
10218  TRACEmodeTime.set(0)
10219 #
10220 def onCanvasShowTcur(event):
10221  global ShowTCur
10222 
10223  if ShowTCur.get() == 0:
10224  ShowTCur.set(1)
10225  else:
10226  ShowTCur.set(0)
10227 #
10228 def onCanvasShowVcur(event):
10229  global ShowVCur
10230 
10231  if ShowVCur.get() == 0:
10232  ShowVCur.set(1)
10233  else:
10234  ShowVCur.set(0)
10235 #
10236 def onCanvasXYRightClick(event):
10237  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus, XYca
10238 
10239  XCursor = event.x
10240  YCursor = event.y
10241  if RUNstatus.get() == 0:
10242  UpdateXYScreen()
10243  XYca.bind_all('<MouseWheel>', onCanvasXYScrollClick)
10244 #
10245 def onCanvasXYScrollClick(event):
10246  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus
10247  if event.widget == XYca:
10248  if ShowXCur.get() > 0 or ShowYCur.get() > 0: # move cursors if shown
10249  ShiftKeyDwn = event.state & 1
10250  if ShowXCur.get() > 0 and ShiftKeyDwn == 0:
10251  # respond to Linux or Windows wheel event
10252  if event.num == 5 or event.delta == -120:
10253  XCursor -= 1
10254  if event.num == 4 or event.delta == 120:
10255  XCursor += 1
10256  # XCursor = XCursor + event.delta/100
10257  elif ShowYCur.get() > 0 or ShiftKeyDwn == 1:
10258  # respond to Linux or Windows wheel event
10259  if event.num == 5 or event.delta == -120:
10260  YCursor += 1
10261  if event.num == 4 or event.delta == 120:
10262  YCursor -= 1
10263  #YCursor = YCursor - event.delta/100
10264  if RUNstatus.get() == 0:
10265  UpdateXYScreen()
10266 #
10267 def onCanvasXYLeftClick(event):
10268  global X0LXY # Left top X value
10269  global Y0TXY # Left top Y value
10270  global GRWXY # Screenwidth
10271  global GRHXY # Screenheight
10272  global FontSize
10273  global XYca
10274  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
10275  global TMsb, CHAsbxy, CHBsbxy, CHAIsbxy, CHBIsbxy, MarkerScale
10276  global CHAVPosEntryxy, CHAIPosEntryxy, CHBVPosEntryxy, CHBIPosEntryxy
10277  global SAMPLErate, RUNstatus, MarkerNum, PrevX, PrevY
10278  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
10279  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
10280  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
10281  # add markers only if stopped
10282  #
10283  if (RUNstatus.get() == 0):
10284  MarkerNum = MarkerNum + 1
10285  try:
10286  CH1pdvRange = float(eval(CHAsbxy.get()))
10287  except:
10288  CHAsbxy.delete(0,END)
10289  CHAsbxy.insert(0, CH1pdvRange)
10290  try:
10291  CH2pdvRange = float(eval(CHBsbxy.get()))
10292  except:
10293  CHBsb.delete(0,END)
10294  CHBsb.insert(0, CH2pdvRange)
10295  try:
10296  CH1IpdvRange = float(eval(CHAIsbxy.get()))
10297  except:
10298  CHAIsbxy.delete(0,END)
10299  CHAIsbxy.insert(0, CH1IpdvRange)
10300  try:
10301  CH2IpdvRange = float(eval(CHBIsbxy.get()))
10302  except:
10303  CHBIsbxy.delete(0,END)
10304  CHBIsbxy.insert(0, CH2IpdvRange)
10305  # get the vertical offsets
10306  try:
10307  CHAOffset = float(eval(CHAVPosEntryxy.get()))
10308  except:
10309  CHAVPosEntryxy.delete(0,END)
10310  CHAVPosEntryxy.insert(0, CHAOffset)
10311  try:
10312  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
10313  except:
10314  CHAIPosEntryxy.delete(0,END)
10315  CHAIPosEntryxy.insert(0, CHAIOffset)
10316  try:
10317  CHBOffset = float(eval(CHBVPosEntryxy.get()))
10318  except:
10319  CHBVPosEntryxy.delete(0,END)
10320  CHBVPosEntryxy.insert(0, CHBOffset)
10321  try:
10322  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
10323  except:
10324  CHBIPosEntryxy.delete(0,END)
10325  CHBIPosEntryxy.insert(0, CHBIOffset)
10326  # prevent divide by zero error
10327  if CH1pdvRange < 0.001:
10328  CH1pdvRange = 0.001
10329  if CH2pdvRange < 0.001:
10330  CH2pdvRange = 0.001
10331  if CH1IpdvRange < 1.0:
10332  CH1IpdvRange = 1.0
10333  if CH2IpdvRange < 1.0:
10334  CH2IpdvRange = 1.0
10335  try:
10336  HoldOff = float(eval(HoldOffentry.get()))
10337  if HoldOff < 0:
10338  HoldOff = 0
10339  except:
10340  HoldOffentry.delete(0,END)
10341  HoldOffentry.insert(0, HoldOff)
10342  #
10343  Yconv1 = float(GRHXY/10) / CH1pdvRange # Conversion factors from samples to screen points
10344  Xconv1 = float(GRWXY/10) / CH1pdvRange
10345  Yconv2 = float(GRHXY/10) / CH2pdvRange
10346  Xconv2 = float(GRWXY/10) / CH2pdvRange
10347  YIconv1 = float(GRHXY/10) / CH1IpdvRange
10348  YIconv2 = float(GRHXY/10) / CH2IpdvRange
10349  COLORmarker = COLORtext
10350  Yoffset1 = CHAOffset
10351  c1 = GRHXY / 2 + Y0TXY # fixed correction channel A
10352  xc1 = GRWXY / 2 + X0LXY
10353  c2 = GRHXY / 2 + Y0TXY # fixed correction channel B
10354  # draw X at marker point and number
10355  XYca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
10356  XYca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
10357  XYca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor="w", font=("arial", FontSize ))
10358  V_label = str(MarkerNum) + " "
10359  x = X0LXY + 5
10360  y = Y0TXY + 3 + (MarkerNum*10)
10361  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset # preset the variable
10362  if (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==3 or Ysignal.get()==5):
10363  yvolts = ((event.y-c2)/Yconv2) - CHBOffset
10364  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
10365  VyString = ' {0:.3f} '.format(-yvolts)
10366  VxString = ' {0:.3f} '.format(-xvolts)
10367  V_label = V_label + VxString + " V, " + VyString + " V"
10368  if MarkerNum > 1:
10369  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
10370  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10371  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
10372  PrevY = yvolts
10373  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==1 or Ysignal.get()==5):
10374  yvolts = ((event.y-c1)/Yconv1) - CHAOffset
10375  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
10376  VyString = ' {0:.3f} '.format(-yvolts)
10377  VxString = ' {0:.3f} '.format(-xvolts)
10378  V_label = V_label + VxString + " V, " + VyString + " V"
10379  if MarkerNum > 1:
10380  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
10381  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10382  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
10383  PrevY = yvolts
10384  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
10385  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
10386  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
10387  VxString = ' {0:.3f} '.format(-xvolts)
10388  VyString = ' {0:.1f} '.format(-ymA)
10389  V_label = V_label + VxString + " V, " + VyString + " mA"
10390  if MarkerNum > 1:
10391  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
10392  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10393  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
10394  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
10395  V_label = V_label + ", dV/dI " + DeltaR
10396  PrevY = ymA
10397  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
10398  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
10399  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
10400  VxString = ' {0:.3f} '.format(-xvolts)
10401  VyString = ' {0:.1f} '.format(-ymA)
10402  V_label = V_label + VxString + " V, " + VyString + " mA"
10403  if MarkerNum > 1:
10404  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
10405  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10406  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
10407  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
10408  V_label = V_label + ", dV/dI " + DeltaR
10409  PrevY = ymA
10410  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
10411  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
10412  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
10413  VxString = ' {0:.3f} '.format(-xvolts)
10414  VyString = ' {0:.1f} '.format(-ymA)
10415  V_label = V_label + VxString + " V, " + VyString + " mA"
10416  if MarkerNum > 1:
10417  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
10418  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10419  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
10420  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
10421  V_label = V_label + ", dV/dI " + DeltaR
10422  PrevY = ymA
10423  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
10424  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
10425  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
10426  VxString = ' {0:.3f} '.format(-xvolts)
10427  VyString = ' {0:.1f} '.format(-ymA)
10428  V_label = V_label + VxString + " V, " + VyString + " mA"
10429  if MarkerNum > 1:
10430  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
10431  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10432  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
10433  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
10434  V_label = V_label + ", dV/dI " + DeltaR
10435  PrevY = ymA
10436  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
10437  PrevX = xvolts
10438 #
10439 # Some DSP functions
10440 #
10441 # Generate Time-series From Half-spectrum code block
10442 # takes: a desired noise spectral density array (freq)
10443 # the sample rate of the time series (fs),
10444 # returns a time series of voltage samples that can be sent to the AWG
10445 #
10446 # DC in first element.
10447 # Output length is 2x input length
10448 def time_points_from_freq(freq, fs=1, density=False):
10449  N=len(freq)
10450  rnd_ph_pos = (numpy.ones(N-1, dtype=numpy.complex)*
10451  numpy.exp(1j*numpy.random.uniform
10452  (0.0,2.0*numpy.pi, N-1)))
10453  rnd_ph_neg = numpy.flip(numpy.conjugate(rnd_ph_pos))
10454  rnd_ph_full = numpy.concatenate(([1],rnd_ph_pos,[1], rnd_ph_neg))
10455  r_s_full = numpy.concatenate((freq, numpy.roll(numpy.flip(freq), 1)))
10456  r_spectrum_rnd_ph = r_s_full * rnd_ph_full
10457  r_time_full = numpy.fft.ifft(r_spectrum_rnd_ph)
10458 # print("RMS imaginary component: ",
10459 # np.std(np.imag(r_time_full)),
10460 # " Should be close to nothing")
10461  if (density == True):
10462  #Note that this N is "predivided" by 2
10463  r_time_full *= N*numpy.sqrt(fs/(N))
10464  return(numpy.real(r_time_full))
10465 #
10466 def TimeSeriesNoise(n, Fsample, mag, b=4):
10467  # Build Noise Time-series
10468  # n = number of Freq Bins
10469  # b = number of noise bands
10470  # Fsample is Sample Rate
10471  # generates four "bands" of mag V/rootHz noise
10472  mag = mag * 0.707106 # scale by 1/sqrt 2 for RMS
10473  width = int(n/(4 * b))
10474  i = 1
10475  aband = numpy.ones(width)
10476  zband = numpy.zeros(width)
10477  bands = numpy.concatenate((aband, zband))
10478  while i < b:
10479  bands = numpy.concatenate((bands, aband, zband))
10480  i = i + 1
10481  bands = bands*mag
10482  bands[0] = 0.0 # Set DC bin content to zero
10483  return time_points_from_freq(bands, fs=Fsample, density=True)
10484 #
10485 # Generate Time samples for single frequency Bin
10486 # Uses IFFT
10487 #
10488 def TimeSeriesSingleTone(n, BinNum, Fsample, mag):
10489  # Build Single tone Time-series
10490  # n = number of Freq Bins
10491  # BinNum = FFT Bin number
10492  # Fsample is Sample Rate
10493  # mag is tone amplitude
10494  bands = numpy.zeros(n)
10495  bands[BinNum] = 1
10496  bands = bands * (mag/2.0)
10497  return time_points_from_freq(bands, fs=Fsample, density=True)
10498 #
10499 def PinkNoise(N, mag):
10500  # Pink noise.
10501  # Pink noise has equal power in bands that are proportionally wide.
10502  # Power spectral density decreases with 3 dB per octave.
10503  # N Length of sample array, mag magnitude scaling factor
10504 
10505  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10506  X = numpy.fft.rfft(x) / N
10507  S = numpy.sqrt(numpy.arange(X.size)+1.0) # +1 to avoid divide by zero
10508  y = numpy.fft.irfft(X/S).real[:N] # extremely tiny value 1e-9 without normalization
10509  z = numpy.ndarray = mag
10510  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10511 
10512  return y
10513 #
10514 def BlueNoise(N, mag):
10515  # Blue noise.
10516  # Power increases with 6 dB per octave.
10517  # Power spectral density increases with 3 dB per octave.
10518  # N Length of sample array, mag magnitude scaling factor
10519 
10520  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10521  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10522  X = numpy.fft.rfft(x) / N
10523  S = numpy.sqrt(numpy.arange(X.size)) # Filter
10524  y = numpy.fft.irfft(X*S).real[:N]
10525  z = numpy.ndarray = mag
10526  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10527 
10528  return y
10529 #
10530 def BrownNoise(N, mag):
10531  # Brown noise.
10532  # Power decreases with -3 dB per octave.
10533  # Power spectral density decreases with 6 dB per octave.
10534  # N Length of sample array, mag magnitude scaling factor
10535 
10536  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10537  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10538  X = numpy.fft.rfft(x) / N
10539  S = numpy.arange(X.size)+1 # Filter
10540  y = numpy.fft.irfft(X/S).real[:N]
10541  z = numpy.ndarray = mag
10542  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10543 
10544  return y
10545 #
10546 def VioletNoise(N, mag):
10547  # Violet noise.
10548  # Power increases with +9 dB per octave.
10549  # Power density increases with +6 dB per octave.
10550  # N Length of sample array, mag magnitude scaling factor
10551 
10552  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10553  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10554  X = numpy.fft.rfft(x) / N
10555  S = numpy.arange(X.size) # Filter
10556  y = numpy.fft.irfft(X*S).real[0:N]
10557  z = numpy.ndarray = mag
10558  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10559 
10560  return y
10561 #
10562 def FourierSawTooth(Length, NumTerms, Ampl):
10563  L = 1 # Length of the interval
10564  x = numpy.linspace(0, 2, Length); # Create Length points on the interval [-3L, 3L]
10565  Const = -2/numpy.pi # Constant factor in the expression for B_n
10566  Sn = Const * numpy.sin(numpy.pi*x) # Initialize vector sum series to zero
10567 
10568  n = 2
10569  while n <= NumTerms:
10570  Const = -Const # Efficient way to implement alternating sign
10571  Bn = Const/n # Coefficients inversely proportional to n
10572  Fn = Bn * numpy.sin(n*numpy.pi*x) # Calculate Fourier term
10573  Sn = Sn + Fn # Add the term to Fourier sum
10574  n = n + 1
10575  Sn = Sn * Ampl # Scale waveform by Ampl
10576  return Sn
10577 #
10578 def SinePower(Length, Power, Phase, Ampl):
10579 
10580  # Generate a Sine Power Pulse waveform of length samples with Symmetry, Phase and Ampl
10581  OutArray = []
10582  t = 1.0E-5 # 10 uSec
10583  frequency = 1.0/(t*Length) # Freq of one cycle
10584  exponent_setting = numpy.clip(Power, -99.999999999, 100.000) / 100.0
10585  if exponent_setting >= 0:
10586  exponent = (1.0 - exponent_setting)
10587  else:
10588  exponent = 1.0 / (1.0 + exponent_setting)
10589  #
10590  Len = 0
10591  while Len < Length:
10592  x = t * Len * frequency + Phase / 360.0
10593  plain_old_sine = numpy.sin(x * 2 * numpy.pi)
10594  # In the SinePower wave function, the 'Power' value is used
10595  # to indicate and exponent between 1.0 and 0.0.
10596  y = numpy.copysign(numpy.abs(plain_old_sine) ** exponent, plain_old_sine)
10597  OutArray.append(Ampl * y)
10598  Len = Len + 1
10599  #
10600  OutArray = numpy.array(OutArray) + 2.5 # Center wavefrom on 2.5 V
10601  return(OutArray)
10602 #
10603 def SchroederPhase(Length, NrTones, Ampl):
10604  # Generate a Schroeder Phase (Chirp) of Length samples and having NrTones
10605  OutArray = []
10606  OutArray = Ampl*numpy.cos(numpy.linspace(0, 2*numpy.pi, Length)) # the fundamental
10607  k = 2
10608  while k <= NrTones:
10609  # Add all harmonics up to NrTones
10610  Harmonic = Ampl*numpy.cos(numpy.linspace(0, k*2*numpy.pi, Length)+(numpy.pi*k*k/NrTones))
10611  OutArray = OutArray + Harmonic
10612  k = k + 1
10613  OutArray = OutArray + 2.5 # Center wavefrom on 2.5 V
10614  return(OutArray)
10615 #
10616 def Wrap(InArray, WrFactor):
10617  # Build new array by skipping WrFactor samples and wrapping back around
10618  # [1,2,3,4,5,6} becomes [1,3,5,2,4,6]
10619  # effectively multiplies the frequency content by WrFactor
10620  OutArray = []
10621  OutArray = numpy.array(OutArray)
10622  InArray = numpy.array(InArray)
10623  EndIndex = len(InArray)
10624  StartIndex = 0
10625  while StartIndex < WrFactor:
10626  OutArray = numpy.concatenate((OutArray, InArray[StartIndex:EndIndex:WrFactor]), axis=0)
10627  StartIndex = StartIndex + 1
10628  return OutArray
10629 #
10630 def UnWrap(InArray, WrFactor):
10631  # Build new array by splitting arrray into WrFactor sections and interleaving samples from each section
10632  # [1,2,3,4,5,6} becomes [1,4,2,5,3,6]
10633  # effectively divided the frequency content by WrFactor
10634  OutArray = []
10635  InArray = numpy.array(InArray)
10636  EndIndex = int(len(InArray)/WrFactor)
10637  StartIndex = 0
10638  while StartIndex < EndIndex:
10639  LoopIndex = 0
10640  while LoopIndex < WrFactor:
10641  OutArray.append(InArray[StartIndex+LoopIndex])
10642  LoopIndex = LoopIndex + 1
10643  StartIndex = StartIndex + 1
10644  OutArray = numpy.array(OutArray)
10645  return OutArray
10646 #
10647 def Write_WAV(data, repeat, filename):
10648  global SAMPLErate
10649  # write data array to mono .wav file 100KSPS
10650  # copy buffer repeat times in output file
10651  # Use : Write_WAV(VBuffB, 2, "write_wave_1.wav")
10652  wavfile = wave.open(filename, "w")
10653  nchannels = 1
10654  sampwidth = 2
10655  framerate = SAMPLErate
10656  amplitude = 32766
10657  nframes = len(data)
10658  comptype = "NONE"
10659  compname = "not compressed"
10660  wavfile.setparams((nchannels,
10661  sampwidth,
10662  framerate,
10663  nframes,
10664  comptype,
10665  compname))
10666  # Normalize data
10667  ArrN = numpy.array(data)
10668  ArrN /= numpy.max(numpy.abs(data))
10669  frames = []
10670  for s in ArrN:
10671  mul = int(s * amplitude)
10672  # print "s: %f mul: %d" % (s, mul)
10673  frames.append(struct.pack('h', mul))
10674  print( len(frames))
10675  frames = ''.join(frames)
10676  print( len(frames))
10677  for x in xrange(0, repeat):
10678  print( x )
10679  wavfile.writeframes(frames)
10680  wavfile.close()
10681 
10682 # =========== Awg functions ==================
10683 def BAWGAAmpl(temp):
10684  global AWGAAmplEntry, AWGAAmplvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10685  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10686 
10687  try:
10688  AWGAAmplvalue = float(eval(AWGAAmplEntry.get()))
10689  except:
10690  AWGAAmplEntry.delete(0,"end")
10691  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10692  #
10693  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10694  if AWGAMode.get() == 0: # Source Voltage measure current mode
10695  if AWGAAmplvalue > 5.00:
10696  AWGAAmplvalue = 5.00
10697  AWGAAmplEntry.delete(0,"end")
10698  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10699  if AWGAAmplvalue < 0.00:
10700  AWGAAmplvalue = 0.00
10701  AWGAAmplEntry.delete(0,"end")
10702  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10703  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10704  if AWGAMode.get() == 0: # Source Voltage measure current mode
10705  if AWGAAmplvalue > (2.5 / AWGA_Ext_Gain.get()):
10706  AWGAAmplvalue = 2.5 / AWGA_Ext_Gain.get()
10707  AWGAAmplEntry.delete(0,"end")
10708  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10709  if AWGAAmplvalue < (-2.50 / AWGA_Ext_Gain.get()):
10710  AWGAAmplvalue = -2.50 / AWGA_Ext_Gain.get()
10711  AWGAAmplEntry.delete(0,"end")
10712  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10713  if AWGAMode.get() == 1: # Source current measure voltage mode
10714  if AWGAAmplvalue > 200.00:
10715  AWGAAmplvalue = 200.00
10716  AWGAAmplEntry.delete(0,"end")
10717  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10718  if AWGAAmplvalue < -200.00:
10719  AWGAAmplvalue = -200.00
10720  AWGAAmplEntry.delete(0,"end")
10721  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10722 #
10723 def BAWGAOffset(temp):
10724  global AWGAOffsetEntry, AWGAOffsetvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10725  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10726 
10727  try:
10728  AWGAOffsetvalue = float(eval(AWGAOffsetEntry.get()))
10729  except:
10730  AWGAOffsetEntry.delete(0,"end")
10731  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10732  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10733  if AWGAMode.get() == 0: # Source Voltage measure current mode
10734  if AWGAOffsetvalue > 5.00:
10735  AWGAOffsetvalue = 5.00
10736  AWGAOffsetEntry.delete(0,"end")
10737  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10738  if AWGAOffsetvalue < 0.00:
10739  AWGAOffsetvalue = 0.00
10740  AWGAOffsetEntry.delete(0,"end")
10741  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10742  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10743  if AWGAOffsetvalue > (2.50-AWGA_Ext_Offset.get()):
10744  AWGAOffsetvalue = 2.50-AWGA_Ext_Offset.get()
10745  AWGAOffsetEntry.delete(0,"end")
10746  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10747  if AWGAOffsetvalue < (-2.50-AWGA_Ext_Offset.get()):
10748  AWGAOffsetvalue = -2.50-AWGA_Ext_Offset.get()
10749  AWGAOffsetEntry.delete(0,"end")
10750  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10751  if AWGAMode.get() == 1: # Source current measure voltage mode
10752  if AWGAOffsetvalue > 200.00:
10753  AWGAOffsetvalue = 200.00
10754  AWGAOffsetEntry.delete(0,"end")
10755  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10756  if AWGAOffsetvalue < -200.00:
10757  AWGAOffsetvalue = -200.00
10758  AWGAOffsetEntry.delete(0,"end")
10759  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10760 #
10761 def BAWGAFreq(temp):
10762  global AWGAFreqEntry, AWGAFreqvalue, AWG_2X, LockFreq
10763  global BodeScreenStatus, BodeDisp, AWGRecLength
10764 
10765  try:
10766  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
10767  except:
10768  AWGAFreqEntry.delete(0,"end")
10769  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10770  if AWG_2X.get() == 1:
10771  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
10772  if AWGAFreqvalue > 90000: # max freq is 90KHz foe Bode Plots
10773  AWGAFreqvalue = 90000
10774  AWGAFreqEntry.delete(0,"end")
10775  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10776  else:
10777  if AWGAFreqvalue > 50000: # max freq is 50KHz
10778  AWGAFreqvalue = 50000
10779  AWGAFreqEntry.delete(0,"end")
10780  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10781  else:
10782  if AWGAFreqvalue > 25000: # max freq is 25KHz
10783  AWGAFreqvalue = 25000
10784  AWGAFreqEntry.delete(0,"end")
10785  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10786  if AWGAFreqvalue < 4.0:
10787  AWGRecLength = 32768*2
10788  else:
10789  AWGRecLength = 32768
10790  if AWGAFreqvalue < 0: # Set negative frequency entry to 10
10791  AWGAFreqvalue = 10
10792  AWGAFreqEntry.delete(0,"end")
10793  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10794  if LockFreq.get() == 1: # If freq lock flag set change AWGB Freq to same value
10795  AWGBFreqEntry.delete(0,"end")
10796  AWGBFreqEntry.insert(0, AWGAFreqvalue)
10797  #UpdateAWGA()
10798 
10799 def ToggleAWGAPhaseDelay():
10800  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10801 
10802  if AWGAPhaseDelay.get() == 1:
10803  AWGAPhaseDelay.set(0)
10804  awgaph.configure(text="Phase")
10805  phasealab.configure(text="Deg")
10806  elif AWGAPhaseDelay.get() == 0:
10807  AWGAPhaseDelay.set(1)
10808  awgaph.configure(text="Delay")
10809  phasealab.configure(text="mSec")
10810 
10811 def BAWGAPhaseDelay():
10812  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10813 
10814  if AWGAPhaseDelay.get() == 0:
10815  phasealab.configure(text="Deg")
10816  awgaph.configure(text="Phase")
10817  elif AWGAPhaseDelay.get() == 1:
10818  phasealab.configure(text="mSec")
10819  awgaph.configure(text="Delay")
10820 
10821 def BAWGAPhase(temp):
10822  global AWGAPhaseEntry, AWGAPhasevalue
10823 
10824  try:
10825  AWGAPhasevalue = float(eval(AWGAPhaseEntry.get()))
10826  except:
10827  AWGAPhaseEntry.delete(0,"end")
10828  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10829 
10830  if AWGAPhasevalue > 360: # max phase is 360 degrees
10831  AWGAPhasevalue = 360
10832  AWGAPhaseEntry.delete(0,"end")
10833  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10834  if AWGAPhasevalue < 0: # min phase is 0 degrees
10835  AWGAPhasevalue = 0
10836  AWGAPhaseEntry.delete(0,"end")
10837  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10838 
10839 def BAWGADutyCycle(temp):
10840  global AWGADutyCycleEntry, AWGADutyCyclevalue
10841 
10842  try:
10843  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))/100
10844  except:
10845  AWGADutyCycleEntry.delete(0,"end")
10846  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10847 
10848  if AWGADutyCyclevalue > 1: # max duty cycle is 100%
10849  AWGADutyCyclevalue = 1
10850  AWGADutyCycleEntry.delete(0,"end")
10851  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue*100)
10852  if AWGADutyCyclevalue < 0: # min duty cycle is 0%
10853  AWGADutyCyclevalue = 0
10854  AWGADutyCycleEntry.delete(0,"end")
10855  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10856  #UpdateAWGA()
10857 
10858 def BAWGAShape():
10859  global AWGAShape, AWGAWave, phasealab, duty1lab
10860 
10861  if AWGAShape.get() == 0:
10862  AWGAWave = 'dc'
10863  duty1lab.config(text="%")
10864  BAWGAPhaseDelay()
10865  if AWGAShape.get() == 1:
10866  AWGAWave = 'sine'
10867  duty1lab.config(text="%")
10868  BAWGAPhaseDelay()
10869  if AWGAShape.get() == 2:
10870  AWGAWave = 'triangle'
10871  duty1lab.config(text="%")
10872  BAWGAPhaseDelay()
10873  if AWGAShape.get() == 3:
10874  AWGAWave = 'sawtooth'
10875  duty1lab.config(text="%")
10876  BAWGAPhaseDelay()
10877  if AWGAShape.get() == 4:
10878  AWGAWave = 'square'
10879  duty1lab.config(text="%")
10880  BAWGAPhaseDelay()
10881  if AWGAShape.get() == 5:
10882  AWGAWave = 'stairstep'
10883  duty1lab.config(text="%")
10884  BAWGAPhaseDelay()
10885  if AWGAShape.get() > 5:
10886  AWGAWave = 'arbitrary'
10887  # UpdateAWGA()
10888 
10889 def AWGAReadFile():
10890  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile
10891 
10892  # Read values from CVS file
10893  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10894  AWGAcsvFile = filename
10895  AWGALoadCSV()
10896 #
10897 def AWGALoadCSV():
10898  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile, AWGAOffsetvalue, AWGAShapeLabel
10899 
10900  BAWGAOffset(0)
10901  try:
10902  CSVFile = open(AWGAcsvFile)
10903  # dialect = csv.Sniffer().sniff(CSVFile.read(128))
10904  CSVFile.seek(0)
10905  #csv_f = csv.reader(CSVFile, dialect)
10906  csv_f = csv.reader(CSVFile, csv.excel)
10907  except:
10908  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10909  # print csv_f.dialect
10910  AWGAwaveform = []
10911  ColumnNum = 0
10912  ColumnSel = 0
10913  RowNum = 0
10914  for row in csv_f:
10915  # print 'found row = ', row
10916  if len(row) > 1 and ColumnSel == 0:
10917  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
10918  ColumnNum = int(RequestColumn) - 1
10919  ColumnLen = str(len(row))
10920  ColumnSel = 1
10921  try:
10922  colnum = 0
10923  for col in row:
10924  if colnum == ColumnNum:
10925  AWGAwaveform.append(float(col))
10926  colnum += 1
10927  except:
10928  print( 'skipping non-numeric row', RowNum)
10929  RowNum += 1
10930  AWGAwaveform = numpy.array(AWGAwaveform)
10931  AWGAwaveform = AWGAwaveform + AWGAOffsetvalue # add DC offset from Max entry
10933  CSVFile.close()
10934  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
10935  AWGAShapeLabel.config(text = "CSV File") # change displayed value
10936  UpdateAwgCont()
10937 
10938 # Split 2X sampled AWGAwaveform array into odd and even sample arrays
10939 def SplitAWGAwaveform():
10940  global AWG_2X, AWGA2X, AWGAwaveform
10941  global AWGFiltA, AWGFiltACoef
10942 
10943  # check if AWG digital filter box checked
10944  if AWGFiltA.get() == 1:
10945  BufLen = len(AWGAwaveform)
10946  CoefLen = len(AWGFiltACoef)/2
10947  AWGAwaveform = numpy.pad(AWGAwaveform, (CoefLen,CoefLen), 'wrap')
10948  AWGAwaveform = numpy.convolve(AWGAwaveform, AWGFiltACoef)
10949  AWGAwaveform = numpy.roll(AWGAwaveform, -CoefLen)
10950  AWGAwaveform = AWGAwaveform[CoefLen:BufLen+CoefLen]
10951 
10952  if AWG_2X.get() == 1:
10953  Tempwaveform = []
10954  AWGA2X = []
10955  AWGA2X = AWGAwaveform[1::2] # odd numbered samples
10956  Tempwaveform = AWGAwaveform[::2] # even numbered samples Tempwaveform
10957  AWGAwaveform = Tempwaveform
10958 #
10959 def AWGANumCycles():
10960  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10961 
10962  if AWGABurstFlag.get() == 1:
10963  AWGACyclesString = askstring("AWG A Burst Mode", "Current number of cycles " + str(AWGACycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGACycles), parent=awgwindow)
10964  if (AWGACyclesString == None): # If Cancel pressed, then None
10965  return
10966  AWGACycles = int(AWGACyclesString)
10967  AWGADelayString = askstring("AWG A Burst Mode", "Current Burst delay " + str(AWGABurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGABurstDelay), parent=awgwindow)
10968  if (AWGADelayString == None): # If Cancel pressed, then None
10969  return
10970  AWGABurstDelay = float(AWGADelayString)
10971  ReMakeAWGwaves()
10972 #
10973 def AWGAReadWAV():
10974  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10975  global AWG_2X, AWGA2X, AWGAwavFile
10976 
10977 # Read values from WAV file
10978  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
10979  AWGAwavFile = filename
10980  AWGALoadWAV()
10981 #
10982 def AWGALoadWAV():
10983  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10984  global AWG_2X, AWGA2X, AWGAwavFile
10985 
10986  try:
10987  spf = wave.open(AWGAwavFile,'r')
10988  except:
10989  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10990  AWGAwaveform = []
10991  AWGBwaveform = []
10992  Length = spf.getnframes()
10993  if Length > 90000:
10994  Length = 90000
10995  # If Stereo put first channel in AWGA and second channel in AWGB
10996  if spf.getnchannels() == 2:
10997  showwarning("Split Stereo","Left to AWGA Right to AWGB", parent=awgwindow)
10998  signal = spf.readframes(Length)
10999  Stereo = numpy.fromstring(signal, 'Int16') # convert strings to Int
11000  n = 0
11001  while n < Length*2:
11002  AWGAwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
11003  n = n + 1
11004  AWGBwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
11005  n = n + 1
11006  AWGAwaveform = numpy.array(AWGAwaveform)
11007  AWGBwaveform = numpy.array(AWGBwaveform)
11008  AWGBShape.set(AWGAShape.get())
11009  else:
11010  #Extract Raw Audio from Wav File
11011  signal = spf.readframes(Length)
11012  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
11013  # offset and scale for 0 5 V range
11014  AWGAwaveform = (WAVsignal * 2.5 / 32768) + 2.5
11015  AWGAwaveform = numpy.array(AWGAwaveform)
11017  spf.close()
11018  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
11019  UpdateAwgCont()
11020 
11021 def AWGAWriteFile():
11022  global AWGAwaveform, AWGALength, awgwindow
11023 
11024  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
11025  numpy.savetxt(filename, AWGAwaveform, delimiter=",", fmt='%2.4f')
11026 
11027 def AWGAMakeMath():
11028  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
11029  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
11030  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
11031  global DFiltACoef, DFiltBCoef, AWGAShapeLabel, AWGALength
11032  global AWG_2X, AWGA2X
11033 
11034  TempString = AWGAMathString
11035  AWGAShapeLabel.config(text = "Math" ) # change displayed value
11036  AWGAMathString = askstring("AWG A Math Formula", "Current Formula: " + AWGAMathString + "\n\nNew Formula:\n", initialvalue=AWGAMathString, parent=awgwindow)
11037  if (AWGAMathString == None): # If Cancel pressed, then None
11038  AWGAMathString = TempString
11039  return
11040  try:
11041  AWGAwaveform = eval(AWGAMathString)
11042  except:
11043  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
11044  AWGAwaveform = numpy.array(AWGAwaveform)
11046  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
11047  UpdateAwgCont()
11048 #
11049 def AWGAConfigMath():
11050  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
11051  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
11052  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
11053  global DFiltACoef, DFiltBCoef, AWGAShapeLabel
11054  global AWG_2X, AWGA2X
11055 
11056  AWGAwaveform = eval(AWGAMathString)
11057  AWGAwaveform = numpy.array(AWGAwaveform)
11059  UpdateAwgCont()
11060 #
11061 def AWGAMakeBodeSine():
11062  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11063  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
11064  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode, AWGRecLength
11065  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11066 
11067  BAWGAAmpl(0)
11068  BAWGAOffset(0)
11069  BAWGAFreq(0)
11070  BAWGAPhase(0)
11071  BAWGADutyCycle(0)
11072  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
11073  if AWGAFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
11074  AWGAShape.set(1)
11075  BAWGAShape()
11076  UpdateAwgCont()
11077  return
11078 
11079  if AWGAFreqvalue > 0.0:
11080  if AWG_2X.get() == 1:
11081  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
11082  else:
11083  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11084  else:
11085  AWGAperiodvalue = 10.0
11086 
11087  if AWGAPhaseDelay.get() == 0:
11088  if AWGAPhasevalue > 0:
11089  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11090  else:
11091  AWGAdelayvalue = 0.0
11092  elif AWGAPhaseDelay.get() == 1:
11093  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11094  Cycles = int(AWGRecLength/AWGAperiodvalue)
11095  if Cycles < 1:
11096  Cycles = 1
11097  RecLength = int(Cycles * AWGAperiodvalue)
11098  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11099  RecLength = RecLength + 1
11100  AWGAwaveform = []
11101  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
11102 
11103  if AWG_Amp_Mode.get() == 0:
11104  if AWGAMode.get() == 1: # convert to mA
11105  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
11106  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
11107  else:
11108  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
11109  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
11110  else:
11111  if AWGAMode.get() == 1: # convert to mA
11112  amplitude = AWGAAmplvalue/1000.0
11113  offset = AWGAOffsetvalue/1000.0
11114  else:
11115  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11116  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11117  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11118  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11119 #
11121  BAWGAPhaseDelay()
11122  duty1lab.config(text="%")
11123  UpdateAwgCont()
11124 #
11125 def AWGAMakeFMSine():
11126  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11127  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
11128  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
11129  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11130 
11131  BAWGAAmpl(0)
11132  BAWGAOffset(0)
11133  BAWGAFreq(0)
11134 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
11135  duty1lab.config(text = "M Index")
11136  phasealab.config(text = "M Freq")
11137 
11138  if AWGAFreqvalue > 0.0:
11139  if AWG_2X.get() == 1:
11140  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
11141  else:
11142  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11143  else:
11144  AWGAperiodvalue = 10.0
11145 
11146  try:
11147  ModFreq = float(eval(AWGAPhaseEntry.get()))
11148  except:
11149  ModFreq = 10
11150  AWGAPhaseEntry.delete(0,"end")
11151  AWGAPhaseEntry.insert(0, ModFreq)
11152 
11153  if ModFreq < 10:
11154  ModFreq = 10
11155  AWGAPhaseEntry.delete(0,"end")
11156  AWGAPhaseEntry.insert(0, ModFreq)
11157 
11158  if AWG_2X.get() == 1:
11159  MODperiodvalue = (BaseSampleRate*2)/ModFreq
11160  else:
11161  MODperiodvalue = BaseSampleRate/ModFreq
11162 
11163  try:
11164  ModIndex = float(eval(AWGADutyCycleEntry.get()))
11165  except:
11166  ModIndex = 1.0
11167  AWGADutyCycleEntry.delete(0,"end")
11168  AWGADutyCycleEntry.insert(0, ModIndex)
11169 
11170  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
11171  if ModCycles < 1:
11172  ModCycles = 1
11173  RecLength = int(ModCycles * MODperiodvalue)
11174  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11175  RecLength = RecLength + 1
11176  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
11177  AWGAwaveform = []
11178  AWGAwaveform = numpy.sin( (numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) - ModIndex*numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)) )
11179  if AWG_Amp_Mode.get() == 0:
11180  if AWGAMode.get() == 1: # convert to mA
11181  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
11182  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
11183  else:
11184  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
11185  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
11186  else:
11187  if AWGAMode.get() == 1: # convert to mA
11188  amplitude = AWGAAmplvalue/1000.0
11189  offset = AWGAOffsetvalue/1000.0
11190  else:
11191  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11192  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11193  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11194  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11195 #
11196  SplitAWGAwaveform() # if needed
11197  UpdateAwgCont()
11198 #
11199 def AWGAMakeAMSine():
11200  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11201  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
11202  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
11203  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11204 
11205  BAWGAAmpl(0)
11206  BAWGAOffset(0)
11207  BAWGAFreq(0)
11208 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
11209  duty1lab.config(text = "M Index")
11210  phasealab.config(text = "M Freq")
11211 
11212  if AWGAFreqvalue > 0.0:
11213  if AWG_2X.get() == 1:
11214  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
11215  else:
11216  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11217  else:
11218  AWGAperiodvalue = 10.0
11219 
11220  try:
11221  ModFreq = float(eval(AWGAPhaseEntry.get()))
11222  except:
11223  ModFreq = 10
11224  AWGAPhaseEntry.delete(0,"end")
11225  AWGAPhaseEntry.insert(0, ModFreq)
11226 
11227  if ModFreq < 10:
11228  ModFreq = 10
11229  AWGAPhaseEntry.delete(0,"end")
11230  AWGAPhaseEntry.insert(0, ModFreq)
11231 
11232  if AWG_2X.get() == 1:
11233  MODperiodvalue = (BaseSampleRate*2)/ModFreq
11234  else:
11235  MODperiodvalue = BaseSampleRate/ModFreq
11236 
11237  try:
11238  ModIndex = float(eval(AWGADutyCycleEntry.get()))/200.0
11239  except:
11240  ModIndex = 50.0
11241  AWGADutyCycleEntry.delete(0,"end")
11242  AWGADutyCycleEntry.insert(0, ModIndex)
11243 
11244  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
11245  if ModCycles < 1:
11246  ModCycles = 1
11247  RecLength = int(ModCycles * MODperiodvalue)
11248  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11249  RecLength = RecLength + 1
11250  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
11251  AWGAwaveform = []
11252  AWGAwaveform = numpy.sin(numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) * (0.5+(ModIndex*(numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)))))
11253  if AWG_Amp_Mode.get() == 0:
11254  if AWGAMode.get() == 1: # convert to mA
11255  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
11256  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
11257  else:
11258  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
11259  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
11260  else:
11261  if AWGAMode.get() == 1: # convert to mA
11262  amplitude = AWGAAmplvalue/1000.0
11263  offset = AWGAOffsetvalue/1000.0
11264  else:
11265  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11266  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11267  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11268  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11269 #
11270  SplitAWGAwaveform() # if needed
11271  UpdateAwgCont()
11272 #
11274  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11275  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
11276  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
11277  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11278 
11279  BAWGAAmpl(0)
11280  BAWGAOffset(0)
11281  BAWGAFreq(0)
11282 #
11283  if AWGAFreqvalue > 0.0:
11284  if AWG_2X.get() == 1:
11285  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
11286  else:
11287  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11288  else:
11289  AWGAperiodvalue = 10.0
11290 
11291  if AWGAPhaseDelay.get() == 0:
11292  if AWGAPhasevalue > 0:
11293  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11294  else:
11295  AWGAdelayvalue = 0.0
11296  elif AWGAPhaseDelay.get() == 1:
11297  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11298 
11299  Cycles = int(AWGRecLength/AWGAperiodvalue)
11300  if Cycles < 1:
11301  Cycles = 1
11302  RecLength = int(Cycles * AWGAperiodvalue)
11303  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11304  RecLength = RecLength + 1
11305  AWGAwaveform = []
11306  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
11307  AWGAwaveform = numpy.absolute(AWGAwaveform) * -1.0
11308  AWGAwaveform = AWGAwaveform + 0.5
11309  AWGAwaveform = AWGAwaveform * 2.0
11310  if AWG_Amp_Mode.get() == 0:
11311  if AWGAMode.get() == 1: # convert to mA
11312  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
11313  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
11314  else:
11315  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
11316  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
11317  else:
11318  if AWGAMode.get() == 1: # convert to mA
11319  amplitude = AWGAAmplvalue/1000.0
11320  offset = AWGAOffsetvalue/1000.0
11321  else:
11322  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11323  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11324  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11325  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11326 #
11328  BAWGAPhaseDelay()
11329  duty1lab.config(text="%")
11330  UpdateAwgCont()
11331 #
11332  SplitAWGAwaveform() # if needed
11333  UpdateAwgCont()
11334 #
11336  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11337  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
11338  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
11339  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11340 
11341  BAWGAAmpl(0)
11342  BAWGAOffset(0)
11343  BAWGAFreq(0)
11344 #
11345  if AWGAFreqvalue > 0.0:
11346  if AWG_2X.get() == 1:
11347  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
11348  else:
11349  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11350  else:
11351  AWGAperiodvalue = 10.0
11352 
11353  if AWGAPhaseDelay.get() == 0:
11354  if AWGAPhasevalue > 0:
11355  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11356  else:
11357  AWGAdelayvalue = 0.0
11358  elif AWGAPhaseDelay.get() == 1:
11359  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11360 
11361  Cycles = int(AWGRecLength/AWGAperiodvalue)
11362  if Cycles < 1:
11363  Cycles = 1
11364  RecLength = int(Cycles * AWGAperiodvalue)
11365  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11366  RecLength = RecLength + 1
11367  AWGAwaveform = []
11368  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
11369  AWGAwaveform = numpy.minimum(AWGAwaveform, numpy.zeros(RecLength))
11370  AWGAwaveform = AWGAwaveform + 0.5
11371  AWGAwaveform = AWGAwaveform * 2.0
11372  # minimum, maximum
11373  if AWG_Amp_Mode.get() == 0:
11374  if AWGAMode.get() == 1: # convert to mA
11375  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
11376  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
11377  else:
11378  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
11379  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
11380  else:
11381  if AWGAMode.get() == 1: # convert to mA
11382  amplitude = AWGAAmplvalue/1000.0
11383  offset = AWGAOffsetvalue/1000.0
11384  else:
11385  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11386  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11387  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11388  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11389 #
11391  BAWGAPhaseDelay()
11392  duty1lab.config(text="%")
11393  UpdateAwgCont()
11394 #
11395  SplitAWGAwaveform() # if needed
11396  UpdateAwgCont()
11397 #
11398 def AWGAMakePWMSine():
11399  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
11400  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11401  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11402  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11403 
11404  BAWGAAmpl(0)
11405  BAWGAOffset(0)
11406  BAWGAFreq(0)
11407  BAWGAPhase(0)
11408  BAWGADutyCycle(0)
11409 
11410  if AWGAFreqvalue > 0.0:
11411  if AWG_2X.get() == 1:
11412  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11413  else:
11414  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11415  else:
11416  AWGAperiodvalue = 0.0
11417  if AWG_Amp_Mode.get() == 1:
11418  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11419  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11420  else:
11421  MaxV = AWGAOffsetvalue
11422  MinV = AWGAAmplvalue
11423 
11424  PulseWidth = int(AWGADutyCyclevalue*100)
11425  PulseSamples = int(AWGAperiodvalue/PulseWidth)
11426  AWGAwaveform = []
11427  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
11428  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
11429  # print(v)
11430  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
11431  if j >= v:
11432  AWGAwaveform.append(MaxV) # j>=v?1:0
11433  else:
11434  AWGAwaveform.append(MinV) # j>=v?1:0
11436  duty1lab.config(text="PWidth")
11437  UpdateAwgCont()
11438 #
11439 def AWGAMakeFourier():
11440  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
11441  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11442  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11443  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11444 
11445  BAWGAAmpl(0)
11446  BAWGAOffset(0)
11447  BAWGAFreq(0)
11448  BAWGADutyCycle(0)
11449 
11450  Max_term = int(AWGADutyCyclevalue*100)
11451  if AWG_2X.get() == 1:
11452  TempRate = (BaseSampleRate*2)
11453  else:
11454  TempRate = BaseSampleRate
11455  AWGAwaveform = []
11456  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGAFreqvalue))) # the fundamental
11457  k = 3
11458  while k <= Max_term:
11459  # Add odd harmonics up to max_term
11460  Harmonic = (math.sin(k*numpy.pi/2.0)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGAFreqvalue))))
11461  AWGAwaveform = AWGAwaveform + Harmonic
11462  k = k + 2 # skip even numbers
11463  if AWG_Amp_Mode.get() == 0:
11464  amplitude = (AWGAOffsetvalue-AWGAAmplvalue)/2.0
11465  offset = (AWGAOffsetvalue+AWGAAmplvalue)/2.0
11466  else:
11467  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11468  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11469  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11471  duty1lab.config(text="Harmonics")
11472  BAWGAPhaseDelay()
11473  UpdateAwgCont()
11474 #
11475 def AWGAMakeSinc():
11476  global AWGAwaveform, AWGSampleRate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11477  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay
11478  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11479  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11480 
11481  BAWGAAmpl(0)
11482  BAWGAOffset(0)
11483  BAWGAFreq(0)
11484  BAWGAPhase(0)
11485  BAWGADutyCycle(0)
11486 
11487  if AWGAFreqvalue > 0.0:
11488  if AWG_2X.get() == 1:
11489  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11490  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11491  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11492  AWGAperiodvalue = AWGAperiodvalue + 1
11493  else:
11494  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11495  SamplesPermS = int(BaseSampleRate/1000) # 100
11496  else:
11497  AWGAperiodvalue = 0.0
11498  if AWG_Amp_Mode.get() == 1:
11499  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11500  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11501  else:
11502  MaxV = AWGAOffsetvalue
11503  MinV = AWGAAmplvalue
11504 
11505  if AWGAPhaseDelay.get() == 0:
11506  if AWGAPhasevalue > 0:
11507  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11508  else:
11509  AWGAdelayvalue = 0.0
11510  elif AWGAPhaseDelay.get() == 1:
11511  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11512 
11513  Cycles = int(AWGADutyCyclevalue*100)
11514  NCycles = -1 * Cycles
11515  AWGAwaveform = []
11516  AWGAwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGAFreqvalue)))
11517  amplitude = (MaxV-MinV) / 2.0
11518  offset = (MaxV+MinV) / 2.0
11519  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11520 
11526  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11528  #BAWGAPhaseDelay()
11529  duty1lab.config(text="Cycles")
11530  BAWGAPhaseDelay()
11531  UpdateAwgCont()
11532 #
11533 def AWGAMakeSSQ():
11534  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11535  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11536  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11537  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11538  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11539 
11540  BAWGAAmpl(0)
11541  BAWGAOffset(0)
11542  BAWGAFreq(0)
11543  BAWGAPhase(0)
11544  BAWGADutyCycle(0)
11545 
11546  if AWGAFreqvalue > 0.0:
11547  if AWG_2X.get() == 1:
11548  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11549  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11550  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11551  AWGAperiodvalue = AWGAperiodvalue + 1
11552  else:
11553  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11554  SamplesPermS = int(BaseSampleRate/1000) # 100
11555  else:
11556  AWGAperiodvalue = 0.0
11557  if AWG_Amp_Mode.get() == 1:
11558  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11559  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11560  else:
11561  MaxV = AWGAOffsetvalue
11562  MinV = AWGAAmplvalue
11563  AWGAwaveform = []
11564  SlopeValue = int(AWGAPhasevalue*SamplesPermS)
11565  if SlopeValue <= 0:
11566  SlopeValue = 1
11567  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11568  if PulseWidth <=0:
11569  PulseWidth = 1
11570  Remainder = int((AWGAperiodvalue - PulseWidth - SlopeValue)/2)
11571  if Remainder <= 0:
11572  Remainder = 1
11573  PulseWidth = PulseWidth - SlopeValue
11574  if PulseWidth <=0:
11575  PulseWidth = 1
11576  StepAmp = (MaxV - MinV)/2
11577  StepOff = (MaxV + MinV)/2
11578  AWGAwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
11579  MidArray = numpy.ones(PulseWidth) * MinV
11580  AWGAwaveform = numpy.insert(AWGAwaveform, SlopeValue, MidArray)
11581  AWGAwaveform = numpy.pad(AWGAwaveform, (Remainder, Remainder), 'edge')
11582  if AWGABurstFlag.get() == 1:
11583  TempOneCycle = AWGAwaveform
11584  for i in range(AWGACycles-1):
11585  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11586  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11587  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11589  duty1lab.config(text="%")
11590  phasealab.config(text = "Rise Time")
11591  UpdateAwgCont()
11592 #
11593 def AWGAMakeTrapazoid():
11594  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11595  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11596  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11597  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11598  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11599 
11600  BAWGAAmpl(0)
11601  BAWGAOffset(0)
11602  BAWGAFreq(0)
11603  BAWGAPhase(0)
11604  BAWGADutyCycle(0)
11605 
11606  if AWGAFreqvalue > 0.0:
11607  if AWG_2X.get() == 1:
11608  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11609  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11610  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11611  AWGAperiodvalue = AWGAperiodvalue + 1
11612  else:
11613  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11614  SamplesPermS = int(BaseSampleRate/1000) # 100
11615  else:
11616  AWGAperiodvalue = 0.0
11617  if AWG_Amp_Mode.get() == 1:
11618  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11619  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11620  else:
11621  MaxV = AWGAOffsetvalue
11622  MinV = AWGAAmplvalue
11623  AWGAwaveform = []
11624  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11625  if SlopeValue <= 0:
11626  SlopeValue = 1
11627  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11628  if PulseWidth <=0:
11629  PulseWidth = 1
11630  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
11631  if Remainder <= 0:
11632  Remainder = 1
11633  PulseWidth = PulseWidth - SlopeValue
11634  if PulseWidth <=0:
11635  PulseWidth = 1
11636  StepValue = (MaxV - MinV) / SlopeValue
11637  SampleValue = MinV
11638  for i in range(SlopeValue):
11639  AWGAwaveform.append(SampleValue)
11640  SampleValue = SampleValue + StepValue
11641  for i in range(PulseWidth):
11642  AWGAwaveform.append(MaxV)
11643  for i in range(SlopeValue):
11644  AWGAwaveform.append(SampleValue)
11645  SampleValue = SampleValue - StepValue
11646  for i in range(Remainder):
11647  AWGAwaveform.append(MinV)
11648  if AWGABurstFlag.get() == 1:
11649  TempOneCycle = AWGAwaveform
11650  for i in range(AWGACycles-1):
11651  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11652  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11653  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11655  duty1lab.config(text="%")
11656  phasealab.config(text = "Rise Time")
11657  UpdateAwgCont()
11658 #
11659 def AWGAMakePulse():
11660  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11661  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11662  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11663  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11664  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11665 
11666  BAWGAAmpl(0)
11667  BAWGAOffset(0)
11668  BAWGAFreq(0)
11669  BAWGAPhase(0)
11670 
11671  try:
11672  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
11673  except:
11674  AWGADutyCycleEntry.delete(0,"end")
11675  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
11676 
11677  if AWGAFreqvalue > 0.0:
11678  if AWG_2X.get() == 1:
11679  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11680  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11681  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11682  AWGAperiodvalue = AWGAperiodvalue + 1
11683  else:
11684  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11685  SamplesPermS = int(BaseSampleRate/1000) # 100
11686  else:
11687  AWGAperiodvalue = 0.0
11688  if AWG_Amp_Mode.get() == 1:
11689  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11690  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11691  else:
11692  MaxV = AWGAOffsetvalue
11693  MinV = AWGAAmplvalue
11694  AWGAwaveform = []
11695  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11696  if SlopeValue <= 0:
11697  SlopeValue = 1
11698  PulseWidth = int(AWGADutyCyclevalue*SamplesPermS) # convert mS to samples
11699  if PulseWidth <=0:
11700  PulseWidth = 1
11701  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
11702  if Remainder <= 0:
11703  Remainder = 1
11704  PulseWidth = PulseWidth - SlopeValue
11705  if PulseWidth <=0:
11706  PulseWidth = 1
11707  StepValue = (MaxV - MinV) / SlopeValue
11708  SampleValue = MinV
11709  for i in range(SlopeValue):
11710  AWGAwaveform.append(SampleValue)
11711  SampleValue = SampleValue + StepValue
11712  for i in range(PulseWidth):
11713  AWGAwaveform.append(MaxV)
11714  for i in range(SlopeValue):
11715  AWGAwaveform.append(SampleValue)
11716  SampleValue = SampleValue - StepValue
11717  for i in range(Remainder):
11718  AWGAwaveform.append(MinV)
11719  if AWGABurstFlag.get() == 1:
11720  TempOneCycle = AWGAwaveform
11721  for i in range(AWGACycles-1):
11722  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11723  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11724  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11726  duty1lab.config(text="Width mS")
11727  phasealab.config(text = "Rise Time")
11728  UpdateAwgCont()
11729 #
11730 def AWGAMakeRamp():
11731  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11732  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11733  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11734  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11735  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11736 
11737  BAWGAAmpl(0)
11738  BAWGAOffset(0)
11739  BAWGAFreq(0)
11740  BAWGAPhase(0)
11741  BAWGADutyCycle(0)
11742 
11743  if AWGAFreqvalue > 0.0:
11744  if AWG_2X.get() == 1:
11745  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11746  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11747  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11748  AWGAperiodvalue = AWGAperiodvalue + 1
11749  else:
11750  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11751  SamplesPermS = int(BaseSampleRate/1000) # 100
11752  else:
11753  AWGAperiodvalue = 0.0
11754  if AWG_Amp_Mode.get() == 1:
11755  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11756  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11757  else:
11758  MaxV = AWGAOffsetvalue
11759  MinV = AWGAAmplvalue
11760  AWGAwaveform = []
11761  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11762  if SlopeValue <= 0:
11763  SlopeValue = 1
11764  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11765  if PulseWidth <=0:
11766  PulseWidth = 1
11767  Remainder = int(AWGAperiodvalue - PulseWidth)
11768  if Remainder <= 0:
11769  Remainder = 1
11770  PulseWidth = PulseWidth - SlopeValue
11771  if PulseWidth <=0:
11772  PulseWidth = 1
11773  StepValue = (MaxV - MinV) / SlopeValue
11774  SampleValue = MinV
11775  for i in range(SlopeValue):
11776  AWGAwaveform.append(SampleValue)
11777  SampleValue = SampleValue + StepValue
11778  for i in range(PulseWidth):
11779  AWGAwaveform.append(MaxV)
11780  for i in range(Remainder):
11781  AWGAwaveform.append(MinV)
11782  if AWGABurstFlag.get() == 1:
11783  TempOneCycle = AWGAwaveform
11784  for i in range(AWGACycles-1):
11785  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11786  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11787  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11789  duty1lab.config(text="%")
11790  phasealab.config(text = "Slope Time")
11791  UpdateAwgCont()
11792 #
11793 def AWGAMakeUpDownRamp():
11794  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, duty1lab
11795  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11796  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11797  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11798  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11799 
11800  BAWGAAmpl(0)
11801  BAWGAOffset(0)
11802  BAWGAFreq(0)
11803  BAWGAPhase(0)
11804  BAWGADutyCycle(0)
11805 
11806  if AWGAFreqvalue > 0.0:
11807  if AWG_2X.get() == 1:
11808  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11809  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11810  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11811  AWGAperiodvalue = AWGAperiodvalue + 1
11812  else:
11813  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
11814  SamplesPermS = int(BaseSampleRate/1000) # 100
11815  else:
11816  AWGAperiodvalue = 0.0
11817  if AWG_Amp_Mode.get() == 1:
11818  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11819  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11820  else:
11821  MaxV = AWGAOffsetvalue
11822  MinV = AWGAAmplvalue
11823  #
11824  if AWGAPhaseDelay.get() == 0:
11825  if AWGAPhasevalue > 0:
11826  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11827  else:
11828  AWGAdelayvalue = 0.0
11829  elif AWGAPhaseDelay.get() == 1:
11830  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11831  #
11832  AWGAwaveform = []
11833  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11834  if PulseWidth <=0:
11835  PulseWidth = 1
11836  Remainder = int(AWGAperiodvalue - PulseWidth)
11837  if Remainder <= 0:
11838  Remainder = 1
11839  UpStepValue = (MaxV - MinV) / PulseWidth
11840  DownStepValue = (MaxV - MinV) / Remainder
11841  SampleValue = MinV
11842  for i in range(PulseWidth):
11843  AWGAwaveform.append(SampleValue)
11844  SampleValue = SampleValue + UpStepValue
11845  for i in range(Remainder):
11846  AWGAwaveform.append(SampleValue)
11847  SampleValue = SampleValue - DownStepValue
11848  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11849  if AWGABurstFlag.get() == 1:
11850  TempOneCycle = AWGAwaveform
11851  for i in range(AWGACycles-1):
11852  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11853  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11854  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11856  BAWGAPhaseDelay()
11857  duty1lab.config(text = "Symmetry")
11858  BAWGAPhaseDelay()
11859  UpdateAwgCont()
11860 #
11861 def AWGAMakeImpulse():
11862  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11863  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue
11864  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11865  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11866  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11867 
11868  BAWGAAmpl(0)
11869  BAWGAOffset(0)
11870  BAWGAFreq(0)
11871  BAWGAPhase(0)
11872  BAWGADutyCycle(0)
11873 
11874  if AWGAFreqvalue > 0.0:
11875  if AWG_2X.get() == 1:
11876  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11877  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11878  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11879  AWGAperiodvalue = AWGAperiodvalue + 1
11880  else:
11881  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11882  SamplesPermS = int(BaseSampleRate/1000) # 100
11883  else:
11884  AWGAperiodvalue = 0.0
11885  if AWG_Amp_Mode.get() == 1:
11886  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11887  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11888  else:
11889  MaxV = AWGAOffsetvalue
11890  MinV = AWGAAmplvalue
11891  AWGAwaveform = []
11892  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue / 2.0)
11893  if AWGAPhaseDelay.get() == 0:
11894  DelayValue = int(AWGAperiodvalue*(AWGAPhasevalue/360))
11895  elif AWGAPhaseDelay.get() == 1:
11896  DelayValue = int(AWGAPhasevalue*SamplesPermS)
11897  for i in range(DelayValue-PulseWidth):
11898  AWGAwaveform.append((MinV+MaxV)/2.0)
11899  for i in range(PulseWidth):
11900  AWGAwaveform.append(MaxV)
11901  for i in range(PulseWidth):
11902  AWGAwaveform.append(MinV)
11903  DelayValue = int(AWGAperiodvalue-DelayValue)
11904  for i in range(DelayValue-PulseWidth):
11905  AWGAwaveform.append((MinV+MaxV)/2.0)
11906  if AWGABurstFlag.get() == 1:
11907  TempOneCycle = AWGAwaveform
11908  for i in range(AWGACycles-1):
11909  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11910  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11911  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11913  duty1lab.config(text = "Duty Cycle")
11914  BAWGAPhaseDelay()
11915  UpdateAwgCont()
11916 
11917 def AWGAMakeUUNoise():
11918  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11919  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11920  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11921  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11922  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11923 
11924  BAWGAAmpl(0)
11925  BAWGAOffset(0)
11926  BAWGAFreq(0)
11927 
11928  if AWGAFreqvalue > 0.0:
11929  if AWG_2X.get() == 1:
11930  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11931  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11932  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11933  AWGAperiodvalue = AWGAperiodvalue + 1
11934  else:
11935  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11936  SamplesPermS = int(BaseSampleRate/1000) # 100
11937  else:
11938  AWGAperiodvalue = 0.0
11939  if AWG_Amp_Mode.get() == 1:
11940  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11941  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11942  else:
11943  if AWGAAmplvalue > AWGAOffsetvalue:
11944  MinV = AWGAOffsetvalue
11945  MaxV = AWGAAmplvalue
11946  else:
11947  MaxV = AWGAOffsetvalue
11948  MinV = AWGAAmplvalue
11949  AWGAwaveform = []
11950  AWGAwaveform = numpy.random.uniform(MinV, MaxV, int(AWGAperiodvalue))
11951  Mid = (MaxV+MinV)/2.0
11952  if AWGABurstFlag.get() == 1:
11953  TempOneCycle = AWGAwaveform
11954  for i in range(AWGACycles-1):
11955  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11956  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11957  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11959  BAWGAPhaseDelay()
11960  UpdateAwgCont()
11961 
11962 def AWGAMakeUGNoise():
11963  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11964  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11965  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11966  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11967  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11968 
11969  BAWGAAmpl(0)
11970  BAWGAOffset(0)
11971  BAWGAFreq(0)
11972 
11973  if AWGAFreqvalue > 0.0:
11974  if AWG_2X.get() == 1:
11975  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11976  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11977  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11978  AWGAperiodvalue = AWGAperiodvalue + 1
11979  else:
11980  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11981  SamplesPermS = int(BaseSampleRate/1000) # 100
11982  else:
11983  AWGAperiodvalue = 0.0
11984  if AWG_Amp_Mode.get() == 1:
11985  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11986  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11987  else:
11988  if AWGAAmplvalue > AWGAOffsetvalue:
11989  MinV = AWGAOffsetvalue
11990  MaxV = AWGAAmplvalue
11991  else:
11992  MaxV = AWGAOffsetvalue
11993  MinV = AWGAAmplvalue
11994  AWGAwaveform = []
11995  AWGAwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGAperiodvalue))
11996  Mid = (MaxV+MinV)/2.0
11997  if AWGABurstFlag.get() == 1:
11998  TempOneCycle = AWGAwaveform
11999  for i in range(AWGACycles-1):
12000  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
12001  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
12002  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
12004  BAWGAPhaseDelay()
12005  UpdateAwgCont()
12006 
12007 def BAWGAModeLabel():
12008  global AWGAMode, AWGAIOMode, AWGAModeLabel, DevID, session, devx, DevOne, CHA, HWRevOne
12009  global EnableScopeOnly, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12010 
12011  if AWGAMode.get() == 0: # Source Voltage measure current mode
12012  label_txt = "SVMI"
12013  elif AWGAMode.get() == 1: # Source current measure voltage mode
12014  label_txt = "SIMV"
12015  elif AWGAMode.get() == 2: # High impedance mode
12016  label_txt = "Hi-Z"
12017  if AWGAIOMode.get() > 0: # Split Input / Output mode
12018  if HWRevOne == "D":
12019  if AWGAMode.get() == 0:
12020  AWGAMode.set(1)
12021  CHA.set_mode('i') # channel must be in source current mode for rev D boards
12022  label_txt = "SIMV"
12023  label_txt = label_txt + " Split I/O"
12024  if EnableScopeOnly == 0:
12025  label_txt = label_txt + " Mode"
12026  AWGAModeLabel.config(text = label_txt ) # change displayed value
12027  ReMakeAWGwaves()
12028  #UpdateAwgCont()
12029 
12030 def UpdateAWGA():
12031  global AWGAAmplvalue, AWGAOffsetvalue, EnableScopeOnly
12032  global AWGAFreqvalue, AWGAPhasevalue, AWGAPhaseDelay
12033  global AWGADutyCyclevalue, FSweepMode, AWGARepeatFlag, AWGSync
12034  global AWGAWave, AWGAMode, AWGATerm, AWGAwaveform, AWGAIOMode
12035  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12036  global amp1lab, off1lab, AWGA2X, AWGA2X, AWGBWave, AWGBRepeatFlag
12037  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12038 
12039  BAWGAAmpl(0)
12040  BAWGAOffset(0)
12041  BAWGAFreq(0)
12042  BAWGAPhase(0)
12043  BAWGADutyCycle(0)
12044  BAWGAShape()
12045 
12046  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
12047  amp1lab.config(text = "Min Ch A" ) # change displayed value
12048  off1lab.config(text = "Max Ch A" ) # change displayed value
12049  else:
12050  amp1lab.config(text = "Amp Ch A" )
12051  off1lab.config(text = "Off Ch A" )
12052 
12053  if AWGAFreqvalue > 0.0:
12054  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
12055  else:
12056  AWGAperiodvalue = 0.0
12057 
12058  if AWGAPhaseDelay.get() == 0:
12059  if AWGAWave == 'square':
12060  AWGAPhasevalue = AWGAPhasevalue + 270.0
12061  if AWGAPhasevalue > 359:
12062  AWGAPhasevalue = AWGAPhasevalue - 360
12063  if AWGAPhasevalue > 0:
12064  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
12065  else:
12066  AWGAdelayvalue = 0.0
12067  elif AWGAPhaseDelay.get() == 1:
12068  AWGAdelayvalue = AWGAPhasevalue * 100
12069 
12070  if AWGATerm.get() == 0: # Open termination
12071  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
12072  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
12073  elif AWGATerm.get() == 1: # 50 Ohm termination to GND
12074  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
12075  devx.ctrl_transfer( 0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
12076  elif AWGATerm.get() == 2: # 50 Ohm termination to +2.5 Volts
12077  devx.ctrl_transfer( 0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
12078  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
12079 
12080  if AWGAWave == 'dc':
12081  if AWG_2X.get() == 2:
12082  AWGAWave == 'arbitrary'
12083  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
12084  else:
12085  if AWGAMode.get() == 0: # Source Voltage measure current mode
12086  if AWGAIOMode.get() == 0:
12087  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
12088  else:
12089  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
12090  CHA.constant(AWGAOffsetvalue)
12091  #
12092  if AWGAMode.get() == 1: # Source current measure voltage mode
12093  if AWGAIOMode.get() == 0:
12094  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
12095  else:
12096  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
12097  CHA.constant(AWGAOffsetvalue/1000)
12098  #
12099  if AWGAMode.get() == 2: # High impedance mode
12100  if AWGAIOMode.get() == 0:
12101  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
12102  else:
12103  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
12104  #
12105  if AWGAIOMode.get() > 0: # Split Input / Output mode
12106  if HWRevOne == "D":
12107  AWGAMode.set(1)
12108  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
12109 #
12110  else:
12111  if AWGAMode.get() == 0: # Source Voltage measure current mode
12112  if AWGAIOMode.get() == 0:
12113  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
12114  else:
12115  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
12116  if AWGAMode.get() == 1: # Source current measure voltage mode
12117  if AWGAIOMode.get() == 0:
12118  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
12119  else:
12120  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
12121  AWGAOffsetvalue = AWGAOffsetvalue/1000
12122  AWGAAmplvalue = AWGAAmplvalue/1000
12123  if AWGAMode.get() == 2: # High impedance mode
12124  if AWGAIOMode.get() == 0:
12125  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
12126  else:
12127  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
12128  else:
12129  if AWG_Amp_Mode.get() == 1:
12130  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
12131  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
12132  else:
12133  MaxV = AWGAOffsetvalue
12134  MinV = AWGAAmplvalue
12135  try:
12136  if AWGAWave == 'sine':
12137  CHA.sine(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
12138  elif AWGAWave == 'triangle':
12139  CHA.triangle(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
12140  elif AWGAWave == 'sawtooth':
12141  CHA.sawtooth(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
12142  elif AWGAWave == 'square':
12143  CHA.square(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue, AWGADutyCyclevalue)
12144  elif AWGAWave == 'stairstep':
12145  CHA.stairstep(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
12146  elif AWGAWave == 'arbitrary':
12147  if EnableScopeOnly == 0:
12148  AddAWGANoise()
12149  if AWGSync.get() == 0:
12150  AWGARepeatFlag.set(1)
12151  if AWG_2X.get() == 2:
12152  AWGAWave == 'arbitrary'
12153  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
12154  else:
12155  CHA.arbitrary(AWGAwaveform, AWGARepeatFlag.get()) # set repeat flag
12156  except:
12157  donothing()
12158  if AWGAIOMode.get() > 0: # Split Input / Output mode
12159  if HWRevOne == "D":
12160  AWGAMode.set(1)
12161  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
12162 #
12163 def AddAWGANoise():
12164  global AWG_2X, AWGB2X, AWGAwaveform
12165  global AWGANoiseEntry, AWGAsbnoise, AWGANoisevalue
12166 
12167  if AWGAsbnoise.get() == "None":
12168  return
12169  else:
12170  try:
12171  AWGANoisevalue = float(eval(AWGANoiseEntry.get()))
12172  except:
12173  AWGANoiseEntry.delete(0,"end")
12174  AWGANoiseEntry.insert(0, AWGANoisevalue)
12175  if AWGANoisevalue == 0.0:
12176  return
12177  AWGANoiseform = []
12178  if AWGAsbnoise.get() == "Gaussian":
12179  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGAwaveform))
12180  else:
12181  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGAwaveform))
12182  AWGAwaveform = AWGAwaveform + AWGANoiseform
12183  if AWG_2X.get() == 2:
12184  if AWGAsbnoise.get() == "Gaussian":
12185  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGB2X))
12186  else:
12187  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGB2X))
12188  AWGB2X = AWGB2X + AWGANoiseform
12189 
12190 def SetBCompA():
12191  global AWGAAmplEntry, AWGBAmplEntry, AWGAOffsetEntry, AWGBOffsetEntry, AWGAFreqEntry, AWGBFreqEntry
12192  global AWGAPhaseEntry, AWGBPhaseEntry, AWGADutyCycleEntry, AWGBDutyCycleEntry, AWGAShape, AWGBShape
12193  global BisCompA, AWGAWave
12194 
12195  # if BisCompA.get() == 1:
12196  # sawp Min and Max values
12197  if AWGAWave == 'dc':
12198  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
12199  AWGBOffsetvalue = 2.5 - (float(eval(AWGAOffsetEntry.get()))-2.5)
12200  AWGBAmplEntry.delete(0,"end")
12201  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12202  AWGBOffsetEntry.delete(0,"end")
12203  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12204  else:
12205  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
12206  AWGBOffsetvalue = float(eval(AWGAOffsetEntry.get()))
12207  AWGBAmplEntry.delete(0,"end")
12208  AWGBAmplEntry.insert(0, AWGBOffsetvalue)
12209  AWGBOffsetEntry.delete(0,"end")
12210  AWGBOffsetEntry.insert(0, AWGBAmplvalue)
12211  # copy everything else
12212  AWGBFreqvalue = float(eval(AWGAFreqEntry.get()))
12213  AWGBFreqEntry.delete(0,"end")
12214  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12215  AWGBPhasevalue = float(eval(AWGAPhaseEntry.get()))
12216  AWGBPhaseEntry.delete(0,"end")
12217  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
12218  AWGBDutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
12219  AWGBDutyCycleEntry.delete(0,"end")
12220  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12221  AWGBShape.set(AWGAShape.get())
12222  #
12223 # ReMakeAWGwaves()
12224 # UpdateAwgCont()
12225 #
12226 # AWG B functions
12227 def AWGBNumCycles():
12228  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12229 
12230  if AWGBBurstFlag.get() == 1:
12231  AWGBCyclesString = askstring("AWG B Burst Mode", "Current number of cycles " + str(AWGBCycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGBCycles), parent=awgwindow)
12232  if (AWGBCyclesString == None): # If Cancel pressed, then None
12233  return
12234  AWGBCycles = int(AWGBCyclesString)
12235  AWGBDelayString = askstring("AWG B Burst Mode", "Current Burst delay " + str(AWGBBurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGBBurstDelay), parent=awgwindow)
12236  if (AWGBDelayString == None): # If Cancel pressed, then None
12237  return
12238  AWGBBurstDelay = float(AWGBDelayString)
12239  ReMakeAWGwaves()
12240 #
12241 def BAWGBAmpl(temp):
12242  global AWGBAmplEntry, AWGBAmplvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12243  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12244 
12245  try:
12246  AWGBAmplvalue = float(eval(AWGBAmplEntry.get()))
12247  except:
12248  AWGBAmplEntry.delete(0,"end")
12249  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12250  #
12251  if AWGBMode.get() == 0: # Source Voltage measure current mode
12252  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max
12253  if AWGBAmplvalue > 5.00:
12254  AWGBAmplvalue = 5.00
12255  AWGBAmplEntry.delete(0,"end")
12256  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12257  if AWGBAmplvalue < 0.00:
12258  AWGBAmplvalue = 0.00
12259  AWGBAmplEntry.delete(0,"end")
12260  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12261  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
12262  if AWGBAmplvalue > (2.5 / AWGB_Ext_Gain.get()):
12263  AWGBAmplvalue = 2.5 / AWGB_Ext_Gain.get()
12264  AWGBAmplEntry.delete(0,"end")
12265  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12266  if AWGBAmplvalue < (-2.50 / AWGB_Ext_Gain.get()):
12267  AWGBAmplvalue = -2.50 / AWGB_Ext_Gain.get()
12268  AWGBAmplEntry.delete(0,"end")
12269  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12270  elif AWGBMode.get() == 1: # Source current measure voltage mode
12271  if AWGBAmplvalue > 200.00:
12272  AWGBAmplvalue = 200.00
12273  AWGBAmplEntry.delete(0,"end")
12274  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12275  if AWGBAmplvalue < -200.00:
12276  AWGBAmplvalue = -200.00
12277  AWGBAmplEntry.delete(0,"end")
12278  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12279 #
12280 def BAWGBOffset(temp):
12281  global AWGBOffsetEntry, AWGBOffsetvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12282  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12283 
12284  try:
12285  AWGBOffsetvalue = float(eval(AWGBOffsetEntry.get()))
12286  except:
12287  AWGBOffsetEntry.delete(0,"end")
12288  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12289  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
12290  if AWGBMode.get() == 0: # Source Voltage measure current mode
12291  if AWGBOffsetvalue > 5.00:
12292  AWGBOffsetvalue = 5.00
12293  AWGBOffsetEntry.delete(0,"end")
12294  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12295  if AWGBOffsetvalue < 0.00:
12296  AWGBOffsetvalue = 0.00
12297  AWGBOffsetEntry.delete(0,"end")
12298  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12299  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
12300  if AWGBOffsetvalue > (2.50-AWGB_Ext_Offset.get()):
12301  AWGBOffsetvalue = 2.50-AWGB_Ext_Offset.get()
12302  AWGBOffsetEntry.delete(0,"end")
12303  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12304  if AWGBOffsetvalue < (-2.50-AWGB_Ext_Offset.get()):
12305  AWGBOffsetvalue = -2.50-AWGB_Ext_Offset.get()
12306  AWGBOffsetEntry.delete(0,"end")
12307  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12308  if AWGBMode.get() == 1: # Source current measure voltage mode
12309  if AWGBOffsetvalue > 200.00:
12310  AWGBOffsetvalue = 200.00
12311  AWGBOffsetEntry.delete(0,"end")
12312  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12313  if AWGBOffsetvalue < -200.00:
12314  AWGBOffsetvalue = -200.00
12315  AWGBOffsetEntry.delete(0,"end")
12316  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12317 #
12318 def BAWGBFreq(temp):
12319  global AWGBFreqEntry, AWGBFreqvalue, AWG_2X
12320  global BodeScreenStatus, BodeDisp, AWGRecLength
12321 
12322  try:
12323  AWGBFreqvalue = float(eval(AWGBFreqEntry.get()))
12324  except:
12325  AWGBFreqEntry.delete(0,"end")
12326  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12327  if AWG_2X.get() == 2:
12328  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
12329  if AWGBFreqvalue > 90000: # max freq is 90KHz for Bode plotting
12330  AWGBFreqvalue = 90000
12331  AWGBFreqEntry.delete(0,"end")
12332  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12333  else:
12334  if AWGBFreqvalue > 50000: # max freq is 50KHz
12335  AWGBFreqvalue = 50000
12336  AWGBFreqEntry.delete(0,"end")
12337  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12338  else:
12339  if AWGBFreqvalue > 25000: # max freq is 25KHz
12340  AWGBFreqvalue = 25000
12341  AWGBFreqEntry.delete(0,"end")
12342  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12343  if AWGBFreqvalue < 4.0:
12344  AWGRecLength = 32768*2
12345  else:
12346  AWGRecLength = 32768
12347  if AWGBFreqvalue < 0: # Set negative frequency entry to 0
12348  AWGBFreqvalue = 10
12349  AWGBFreqEntry.delete(0,"end")
12350  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12351  # UpdateAWGB()
12352 
12353 def ToggleAWGBPhaseDelay():
12354  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
12355 
12356  if AWGBPhaseDelay.get() == 1:
12357  AWGBPhaseDelay.set(0)
12358  awgbph.configure(text="Phase")
12359  phaseblab.configure(text="Deg")
12360  elif AWGBPhaseDelay.get() == 0:
12361  AWGBPhaseDelay.set(1)
12362  awgbph.configure(text="Delay")
12363  phaseblab.configure(text="mSec")
12364 
12365 def BAWGBPhaseDelay():
12366  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
12367 
12368  if AWGBPhaseDelay.get() == 0:
12369  phaseblab.configure(text="Deg")
12370  awgbph.configure(text="Phase")
12371  elif AWGBPhaseDelay.get() == 1:
12372  phaseblab.configure(text="mSec")
12373  awgbph.configure(text="Delay")
12374 
12375 def BAWGBPhase(temp):
12376  global AWGBPhaseEntry, AWGBPhasevalue
12377 
12378  try:
12379  AWGBPhasevalue = float(eval(AWGBPhaseEntry.get()))
12380  except:
12381  AWGBPhaseEntry.delete(0,"end")
12382  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
12383 
12384  if AWGBPhasevalue > 360: # max phase is 360 degrees
12385  AWGBPhasevalue = 360
12386  AWGBPhaseEntry.delete(0,"end")
12387  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
12388  if AWGBPhasevalue < 0: # min phase is 0 degrees
12389  AWGBPhasevalue = 0
12390  AWGBPhaseEntry.delete(0,"end")
12391  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
12392 
12393 def BAWGBDutyCycle(temp):
12394  global AWGBDutyCycleEntry, AWGBDutyCyclevalue
12395 
12396  try:
12397  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))/100
12398  except:
12399  AWGBDutyCycleEntry.delete(0,"end")
12400  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12401 
12402  if AWGBDutyCyclevalue > 1: # max duty cycle is 100%
12403  AWGBDutyCyclevalue = 1
12404  AWGBDutyCycleEntry.delete(0,"end")
12405  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue*100)
12406  if AWGBDutyCyclevalue < 0: # min duty cycle is 0%
12407  AWGBDutyCyclevalue = 0
12408  AWGBDutyCycleEntry.delete(0,"end")
12409  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12410  # UpdateAWGB()
12411 
12412 def BAWGBShape():
12413  global AWGBShape, AWGBWave, duty2lab, AWG_2X, CHA, CHB
12414 
12415  if AWGBShape.get() == 0:
12416  AWGBWave = 'dc'
12417  duty2lab.config(text="%")
12418  BAWGBPhaseDelay()
12419  if AWGBShape.get() == 1:
12420  AWGBWave = 'sine'
12421  duty2lab.config(text="%")
12422  BAWGBPhaseDelay()
12423  if AWGBShape.get() == 2:
12424  AWGBWave = 'triangle'
12425  duty2lab.config(text="%")
12426  BAWGBPhaseDelay()
12427  if AWGBShape.get() == 3:
12428  AWGBWave = 'sawtooth'
12429  duty2lab.config(text="%")
12430  BAWGBPhaseDelay()
12431  if AWGBShape.get() == 4:
12432  AWGBWave = 'square'
12433  duty2lab.config(text="%")
12434  BAWGBPhaseDelay()
12435  if AWGBShape.get() == 5:
12436  AWGBWave = 'stairstep'
12437  duty2lab.config(text="%")
12438  BAWGBPhaseDelay()
12439  if AWGBShape.get() > 5:
12440  AWGBWave = 'arbitrary'
12441  if AWG_2X.get() == 1:
12442  CHB.mode = CHA.mode
12443  AWGBWave = 'arbitrary'
12444  # UpdateAWGB()
12445 
12446 def AWGBReadFile():
12447  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile
12448 
12449  # Read values from CVS file
12450  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
12451  AWGBcsvFile = filename
12452  AWGBLoadCSV()
12453 #
12454 def AWGBLoadCSV():
12455  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile, AWGBOffsetvalue, AWGBShapeLabel
12456 
12457  BAWGBOffset(0)
12458  try:
12459  CSVFile = open(AWGBcsvFile)
12460  # dialect = csv.Sniffer().sniff(CSVFile.read(128), delimiters=None)
12461  CSVFile.seek(0)
12462  #csv_f = csv.reader(CSVFile, dialect)
12463  csv_f = csv.reader(CSVFile, csv.excel)
12464  except:
12465  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
12466  AWGBwaveform = []
12467  ColumnNum = 0
12468  ColumnSel = 0
12469  RowNum = 0
12470  for row in csv_f:
12471  if len(row) > 1 and ColumnSel == 0:
12472  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
12473  ColumnNum = int(RequestColumn) - 1
12474  ColumnLen = str(len(row))
12475  ColumnSel = 1
12476  try:
12477  colnum = 0
12478  for col in row:
12479  if colnum == ColumnNum:
12480  AWGBwaveform.append(float(col))
12481  colnum += 1
12482  except:
12483  print( 'skipping non-numeric row', RowNum)
12484  RowNum += 1
12485  AWGBwaveform = numpy.array(AWGBwaveform)
12486  AWGBwaveform = AWGBwaveform + AWGBOffsetvalue # add DC offset from Max entry
12488  CSVFile.close()
12489  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
12490  AWGBShapeLabel.config(text = "CSV File") # change displayed value
12491  UpdateAwgCont()
12492 
12493 # Split 2X sampled AWGBwaveform array into odd and even sample arrays
12494 def SplitAWGBwaveform():
12495  global AWG_2X, AWGB2X, AWGBwaveform
12496  global AWGFiltB, AWGFiltBCoef
12497 
12498  # check if AWG digital filter box checked
12499  if AWGFiltB.get() == 1:
12500  BufLen = len(AWGBwaveform)
12501  CoefLen = len(AWGFiltBCoef)/2
12502  AWGBwaveform = numpy.pad(AWGBwaveform, (CoefLen,CoefLen), 'wrap')
12503  AWGBwaveform = numpy.convolve(AWGBwaveform, AWGFiltBCoef)
12504  AWGBwaveform = numpy.roll(AWGBwaveform, -CoefLen)
12505  AWGBwaveform = AWGBwaveform[CoefLen:BufLen+CoefLen]
12506 
12507  if AWG_2X.get() == 2:
12508  Tempwaveform = []
12509  AWGB2X = []
12510  AWGB2X = AWGBwaveform[::2] # even numbered samples
12511  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
12512  AWGBwaveform = Tempwaveform
12513 #
12514 def AWGBReadWAV():
12515  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
12516  global AWG_2X, AWGA2X
12517 
12518 # Read values from WAV file
12519  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
12520  AWGBwavFile = filename
12521  AWGBLoadWAV()
12522 #
12523 def AWGBLoadWAV():
12524  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
12525  global AWG_2X, AWGA2X
12526 
12527  try:
12528  spf = wave.open(AWGBwavFile,'r')
12529  except:
12530  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
12531  AWGBwaveform = []
12532  #If Stereo
12533  if spf.getnchannels() == 2:
12534  showwarning("WARNING","Only mono files supported!", parent=awgwindow)
12535  return()
12536  #Extract Raw Audio from Wav File
12537  Length = spf.getnframes()
12538  if Length > 90000: # limit to first 90K samples
12539  Length = 90000
12540  signal = spf.readframes(Length)
12541  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
12542  # offset and scale for 0 5 V range
12543  AWGBwaveform = (WAVsignal * 2.5 / 32768) + 2.5
12544  AWGBwaveform = numpy.array(AWGBwaveform)
12546  spf.close()
12547  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
12548  UpdateAwgCont()
12549 
12550 def AWGBWriteFile():
12551  global AWGBwaveform, AWGBLength, awgwindow
12552 
12553  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
12554  numpy.savetxt(filename, AWGBwaveform, delimiter=",", fmt='%2.4f')
12555 
12556 def AWGBMakeMath():
12557  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
12558  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
12559  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
12560  global DFiltACoef, DFiltBCoef, AWGBShapeLabel, AWGBLength
12561  global AWG_2X, AWGA2X
12562 
12563  TempString = AWGBMathString
12564  AWGBShapeLabel.config(text = "Math" ) # change displayed value
12565  AWGBMathString = askstring("AWG B Math Formula", "Current Formula: " + AWGBMathString + "\n\nNew Formula:\n", initialvalue=AWGBMathString, parent=awgwindow)
12566  if (AWGBMathString == None): # If Cancel pressed, then None
12567  AWGBMathString = TempString
12568  return
12569  try:
12570  AWGBwaveform = eval(AWGBMathString)
12571  except:
12572  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
12573  AWGBwaveform = numpy.array(AWGBwaveform)
12575  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
12576  UpdateAwgCont()
12577 #
12578 def AWGBConfigMath():
12579  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
12580  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
12581  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
12582  global DFiltACoef, DFiltBCoef, AWGBShapeLabel
12583  global AWG_2X, AWGA2X
12584 
12585  AWGBwaveform = eval(AWGBMathString)
12586  AWGBwaveform = numpy.array(AWGBwaveform)
12588  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
12589  UpdateAwgCont()
12590 #
12591 def AWGBMakeFourier():
12592  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBFreqvalue, awgwindow
12593  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12594  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, duty2lab
12595  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12596 
12597  Max_term = int(AWGBDutyCyclevalue*100)
12598 
12599  BAWGBAmpl(0)
12600  BAWGBOffset(0)
12601  BAWGBFreq(0)
12602  if AWG_2X.get() == 1:
12603  TempRate = (BaseSampleRate*2)
12604  else:
12605  TempRate = BaseSampleRate
12606  AWGBwaveform = []
12607  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGBFreqvalue))) # the fundamental
12608  k = 3
12609  while k <= Max_term:
12610  # Add odd harmonics up to max_term
12611  Harmonic = (math.sin(k*numpy.pi/2)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGBFreqvalue))))
12612  AWGBwaveform = AWGBwaveform + Harmonic
12613  k = k + 2 # skip even numbers
12614  if AWG_Amp_Mode.get() == 0:
12615  amplitude = (AWGBOffsetvalue-AWGBAmplvalue)/2
12616  offset = (AWGBOffsetvalue+AWGBAmplvalue)/2
12617  else:
12618  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
12619  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
12620  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12622  duty2lab.config(text="Harmonics")
12623  BAWGBPhaseDelay()
12624  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
12625  UpdateAwgCont()
12626 #
12627 def AWGBMakeBodeSine():
12628  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12629  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
12630  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
12631  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
12632 
12633  BAWGBAmpl(0)
12634  BAWGBOffset(0)
12635  BAWGBFreq(0)
12636  BAWGBPhase(0)
12637  BAWGBDutyCycle(0)
12638  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
12639  if AWGBFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
12640  AWGBShape.set(1)
12641  BAWGBShape()
12642  UpdateAwgCont()
12643  return
12644 
12645  if AWGBFreqvalue > 0.0:
12646  if AWG_2X.get() == 2:
12647  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12648  else:
12649  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12650  else:
12651  AWGBperiodvalue = 10.0
12652 
12653  if AWGBPhaseDelay.get() == 0:
12654  if AWGBPhasevalue > 0:
12655  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12656  else:
12657  AWGBdelayvalue = 0.0
12658  elif AWGBPhaseDelay.get() == 1:
12659  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
12660  Cycles = int(AWGRecLength/AWGBperiodvalue)
12661  if Cycles < 1:
12662  Cycles = 1
12663  RecLength = int(Cycles * AWGBperiodvalue)
12664  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12665  RecLength = RecLength + 1
12666  AWGBwaveform = []
12667  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
12668 
12669  if AWG_Amp_Mode.get() == 0:
12670  if AWGBMode.get() == 1: # convert to mA
12671  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
12672  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
12673  else:
12674  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
12675  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
12676  else:
12677  if AWGBMode.get() == 1: # convert to mA
12678  amplitude = AWGBAmplvalue/1000.0
12679  offset = AWGBOffsetvalue/1000.0
12680  else:
12681  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
12682  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
12683  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12684  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12685  #
12686  if AWG_2X.get() == 2:
12687  Tempwaveform = []
12688  AWGB2X = []
12689  AWGB2X = AWGBwaveform[::2] # even numbered samples
12690  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
12691  AWGBwaveform = Tempwaveform
12692  BAWGBPhaseDelay()
12693  duty2lab.config(text="%")
12694  UpdateAwgCont()
12695 #
12697  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12698  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
12699  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
12700  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
12701 
12702  BAWGBAmpl(0)
12703  BAWGBOffset(0)
12704  BAWGBFreq(0)
12705  BAWGBPhase(0)
12706  BAWGBDutyCycle(0)
12707  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
12708  if AWGBFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
12709  AWGBShape.set(1)
12710  BAWGBShape()
12711  UpdateAwgCont()
12712  return
12713 
12714  if AWGBFreqvalue > 0.0:
12715  if AWG_2X.get() == 2:
12716  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12717  else:
12718  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12719  else:
12720  AWGBperiodvalue = 10.0
12721 
12722  if AWGBPhaseDelay.get() == 0:
12723  if AWGBPhasevalue > 0:
12724  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12725  else:
12726  AWGBdelayvalue = 0.0
12727  elif AWGBPhaseDelay.get() == 1:
12728  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
12729  Cycles = int(AWGRecLength/AWGBperiodvalue)
12730  if Cycles < 1:
12731  Cycles = 1
12732  RecLength = int(Cycles * AWGBperiodvalue)
12733  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12734  RecLength = RecLength + 1
12735  AWGBwaveform = []
12736  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
12737  AWGBwaveform = numpy.absolute(AWGBwaveform) * -1.0
12738  AWGBwaveform = AWGBwaveform + 0.5
12739  AWGBwaveform = AWGBwaveform * 2.0
12740  if AWG_Amp_Mode.get() == 0:
12741  if AWGBMode.get() == 1: # convert to mA
12742  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
12743  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
12744  else:
12745  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
12746  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
12747  else:
12748  if AWGBMode.get() == 1: # convert to mA
12749  amplitude = AWGBAmplvalue/1000.0
12750  offset = AWGBOffsetvalue/1000.0
12751  else:
12752  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
12753  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
12754  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12755  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12756  #
12757  if AWG_2X.get() == 2:
12758  Tempwaveform = []
12759  AWGB2X = []
12760  AWGB2X = AWGBwaveform[::2] # even numbered samples
12761  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
12762  AWGBwaveform = Tempwaveform
12763  BAWGBPhaseDelay()
12764  duty2lab.config(text="%")
12765  UpdateAwgCont()
12766 #
12768  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12769  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
12770  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
12771  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
12772 
12773  BAWGBAmpl(0)
12774  BAWGBOffset(0)
12775  BAWGBFreq(0)
12776  BAWGBPhase(0)
12777  BAWGBDutyCycle(0)
12778  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
12779  if AWGBFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
12780  AWGBShape.set(1)
12781  BAWGBShape()
12782  UpdateAwgCont()
12783  return
12784 
12785  if AWGBFreqvalue > 0.0:
12786  if AWG_2X.get() == 2:
12787  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12788  else:
12789  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12790  else:
12791  AWGBperiodvalue = 10.0
12792 
12793  if AWGBPhaseDelay.get() == 0:
12794  if AWGBPhasevalue > 0:
12795  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12796  else:
12797  AWGBdelayvalue = 0.0
12798  elif AWGBPhaseDelay.get() == 1:
12799  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
12800  Cycles = int(AWGRecLength/AWGBperiodvalue)
12801  if Cycles < 1:
12802  Cycles = 1
12803  RecLength = int(Cycles * AWGBperiodvalue)
12804  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12805  RecLength = RecLength + 1
12806  AWGBwaveform = []
12807  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
12808  AWGBwaveform = numpy.minimum(AWGBwaveform, numpy.zeros(RecLength))
12809  AWGBwaveform = AWGBwaveform + 0.5
12810  AWGBwaveform = AWGBwaveform * 2.0
12811  if AWG_Amp_Mode.get() == 0:
12812  if AWGBMode.get() == 1: # convert to mA
12813  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
12814  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
12815  else:
12816  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
12817  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
12818  else:
12819  if AWGBMode.get() == 1: # convert to mA
12820  amplitude = AWGBAmplvalue/1000.0
12821  offset = AWGBOffsetvalue/1000.0
12822  else:
12823  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
12824  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
12825  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12826  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12827  #
12828  if AWG_2X.get() == 2:
12829  Tempwaveform = []
12830  AWGB2X = []
12831  AWGB2X = AWGBwaveform[::2] # even numbered samples
12832  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
12833  AWGBwaveform = Tempwaveform
12834  BAWGBPhaseDelay()
12835  duty2lab.config(text="%")
12836  UpdateAwgCont()
12837 #
12838 def AWGBMakePWMSine():
12839  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength
12840  global AWGBDutyCyclevalue, AWGBFreqvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12841  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12842  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12843 
12844  BAWGBAmpl(0)
12845  BAWGBOffset(0)
12846  BAWGBFreq(0)
12847  BAWGBPhase(0)
12848  BAWGBDutyCycle(0)
12849 
12850  if AWGBFreqvalue > 0.0:
12851  if AWG_2X.get() == 2:
12852  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12853  else:
12854  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12855  else:
12856  AWGBperiodvalue = 0.0
12857  if AWG_Amp_Mode.get() == 1:
12858  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12859  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12860  else:
12861  MaxV = AWGBOffsetvalue
12862  MinV = AWGBAmplvalue
12863 
12864  PulseWidth = int(AWGBDutyCyclevalue*100)
12865  PulseSamples = int(AWGBperiodvalue/PulseWidth)
12866  AWGBwaveform = []
12867  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
12868  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
12869  # print(v)
12870  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
12871  if j >= v:
12872  AWGBwaveform.append(MaxV) # j>=v?1:0
12873  else:
12874  AWGBwaveform.append(MinV) # j>=v?1:0
12876  duty2lab.config(text="PWidth")
12877  UpdateAwgCont()
12878 #
12879 def AWGBMakeSinc():
12880  global AWGBwaveform, AWGSampleRate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12881  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay
12882  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12883  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12884 
12885  BAWGBAmpl(0)
12886  BAWGBOffset(0)
12887  BAWGBFreq(0)
12888  BAWGBPhase(0)
12889  BAWGBDutyCycle(0)
12890 
12891  if AWGBFreqvalue > 0.0:
12892  if AWG_2X.get() == 1:
12893  AWGBperiodvalue = int((BaseSampleRate*2)/AWGBFreqvalue)
12894  if AWGBperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12895  AWGBperiodvalue = AWGBperiodvalue + 1
12896  else:
12897  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12898  else:
12899  AWGBperiodvalue = 0.0
12900  if AWG_Amp_Mode.get() == 1:
12901  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12902  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12903  else:
12904  MaxV = AWGBOffsetvalue
12905  MinV = AWGBAmplvalue
12906 
12907  if AWGBPhaseDelay.get() == 0:
12908  if AWGBPhasevalue > 0:
12909  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12910  else:
12911  AWGBdelayvalue = 0.0
12912  elif AWGBPhaseDelay.get() == 1:
12913  AWGBdelayvalue = AWGBPhasevalue * SAMPLErate / 1000
12914 
12915  Cycles = int(AWGBDutyCyclevalue*100)
12916  NCycles = -1 * Cycles
12917  AWGBwaveform = []
12918  AWGBwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGBFreqvalue)))
12919  amplitude = (MaxV-MinV) / 2.0
12920  offset = (MaxV+MinV) / 2.0
12921  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12922 
12928  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12930  duty2lab.config(text="Cycles")
12931  BAWGBPhaseDelay()
12932  UpdateAwgCont()
12933 #
12934 def AWGBMakeSSQ():
12935  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12936  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12937  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12938  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12939  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12940  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12941 
12942  BAWGBAmpl(0)
12943  BAWGBOffset(0)
12944  BAWGBFreq(0)
12945  BAWGBPhase(0)
12946  BAWGBDutyCycle(0)
12947 
12948  if AWGBFreqvalue > 0.0:
12949  if AWG_2X.get() == 2:
12950  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12951  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12952  else:
12953  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12954  SamplesPermS = int(BaseSampleRate/1000) # 100
12955  else:
12956  AWGBperiodvalue = 0.0
12957  if AWG_Amp_Mode.get() == 1:
12958  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12959  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12960  else:
12961  MaxV = AWGBOffsetvalue
12962  MinV = AWGBAmplvalue
12963  AWGBwaveform = []
12964  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
12965  if SlopeValue <= 0:
12966  SlopeValue = 1
12967  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12968  if PulseWidth <=0:
12969  PulseWidth = 1
12970  Remainder = int((AWGBperiodvalue - PulseWidth - SlopeValue)/2)
12971  if Remainder <= 0:
12972  Remainder = 1
12973  PulseWidth = PulseWidth - SlopeValue
12974  if PulseWidth <=0:
12975  PulseWidth = 1
12976  StepAmp = (MaxV - MinV)/2
12977  StepOff = (MaxV + MinV)/2
12978  AWGBwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
12979  MidArray = numpy.ones(PulseWidth) * MinV
12980  AWGBwaveform = numpy.insert(AWGBwaveform, SlopeValue, MidArray)
12981  AWGBwaveform = numpy.pad(AWGBwaveform, (Remainder, Remainder), 'edge')
12982  if AWGBBurstFlag.get() == 1:
12983  TempOneCycle = AWGBwaveform
12984  for i in range(AWGBCycles-1):
12985  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12986  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12987  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12989  duty2lab.config(text="%")
12990  phaseblab.config(text = "Rise Time")
12991  UpdateAwgCont()
12992 #
12993 def AWGBMakeTrapazoid():
12994  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12995  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12996  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12997  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12998  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12999  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13000 
13001  BAWGBAmpl(0)
13002  BAWGBOffset(0)
13003  BAWGBFreq(0)
13004  BAWGBPhase(0)
13005  BAWGBDutyCycle(0)
13006 
13007  if AWGBFreqvalue > 0.0:
13008  if AWG_2X.get() == 2:
13009  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13010  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13011  else:
13012  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13013  SamplesPermS = int(BaseSampleRate/1000) # 100
13014  else:
13015  AWGBperiodvalue = 0.0
13016  if AWG_Amp_Mode.get() == 1:
13017  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13018  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13019  else:
13020  MaxV = AWGBOffsetvalue
13021  MinV = AWGBAmplvalue
13022  AWGBwaveform = []
13023  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
13024  if SlopeValue <= 0:
13025  SlopeValue = 1
13026  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
13027  if PulseWidth <=0:
13028  PulseWidth = 1
13029  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
13030  if Remainder <= 0:
13031  Remainder = 1
13032  PulseWidth = PulseWidth - SlopeValue
13033  if PulseWidth <=0:
13034  PulseWidth = 1
13035  StepValue = (MaxV - MinV) / SlopeValue
13036  SampleValue = MinV
13037  for i in range(SlopeValue):
13038  AWGBwaveform.append(SampleValue)
13039  SampleValue = SampleValue + StepValue
13040  for i in range(PulseWidth):
13041  AWGBwaveform.append(MaxV)
13042  for i in range(SlopeValue):
13043  AWGBwaveform.append(SampleValue)
13044  SampleValue = SampleValue - StepValue
13045  for i in range(Remainder):
13046  AWGBwaveform.append(MinV)
13047  if AWGBBurstFlag.get() == 1:
13048  TempOneCycle = AWGBwaveform
13049  for i in range(AWGBCycles-1):
13050  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13051  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13052  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
13054  duty2lab.config(text="%")
13055  phaseblab.config(text = "Rise Time")
13056  UpdateAwgCont()
13057 #
13058 def AWGBMakePulse():
13059  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
13060  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
13061  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13062  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13063  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13064  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13065 
13066  BAWGBAmpl(0)
13067  BAWGBOffset(0)
13068  BAWGBFreq(0)
13069  BAWGBPhase(0)
13070 
13071  try:
13072  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))
13073  except:
13074  AWGBDutyCycleEntry.delete(0,"end")
13075  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
13076 
13077  if AWGBFreqvalue > 0.0:
13078  if AWG_2X.get() == 2:
13079  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13080  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13081  else:
13082  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13083  SamplesPermS = int(BaseSampleRate/1000) # 100
13084  else:
13085  AWGBperiodvalue = 0.0
13086  if AWG_Amp_Mode.get() == 1:
13087  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13088  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13089  else:
13090  MaxV = AWGBOffsetvalue
13091  MinV = AWGBAmplvalue
13092  AWGBwaveform = []
13093  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
13094  if SlopeValue <= 0:
13095  SlopeValue = 1
13096  PulseWidth = int(AWGBDutyCyclevalue*SamplesPermS) # convert mS to samples
13097  if PulseWidth <=0:
13098  PulseWidth = 1
13099  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
13100  if Remainder <= 0:
13101  Remainder = 1
13102  PulseWidth = PulseWidth - SlopeValue
13103  if PulseWidth <=0:
13104  PulseWidth = 1
13105  StepValue = (MaxV - MinV) / SlopeValue
13106  SampleValue = MinV
13107  for i in range(SlopeValue):
13108  AWGBwaveform.append(SampleValue)
13109  SampleValue = SampleValue + StepValue
13110  for i in range(PulseWidth):
13111  AWGBwaveform.append(MaxV)
13112  for i in range(SlopeValue):
13113  AWGBwaveform.append(SampleValue)
13114  SampleValue = SampleValue - StepValue
13115  for i in range(Remainder):
13116  AWGBwaveform.append(MinV)
13117  if AWGBBurstFlag.get() == 1:
13118  TempOneCycle = AWGBwaveform
13119  for i in range(AWGBCycles-1):
13120  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13121  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13122  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
13124  duty2lab.config(text="Width mS")
13125  phaseblab.config(text = "Rise Time")
13126  UpdateAwgCont()
13127 #
13128 def AWGBMakeRamp():
13129  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
13130  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
13131  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13132  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13133  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13134  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13135 
13136  BAWGBAmpl(0)
13137  BAWGBOffset(0)
13138  BAWGBFreq(0)
13139  BAWGBPhase(0)
13140  BAWGBDutyCycle(0)
13141 
13142  if AWGBFreqvalue > 0.0:
13143  if AWG_2X.get() == 2:
13144  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13145  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13146  else:
13147  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13148  SamplesPermS = int(BaseSampleRate/1000) # 100
13149  else:
13150  AWGBperiodvalue = 0.0
13151  if AWG_Amp_Mode.get() == 1:
13152  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13153  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13154  else:
13155  MaxV = AWGBOffsetvalue
13156  MinV = AWGBAmplvalue
13157  AWGBwaveform = []
13158  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
13159  if SlopeValue <= 0:
13160  SlopeValue = 1
13161  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
13162  if PulseWidth <=0:
13163  PulseWidth = 1
13164  Remainder = int(AWGBperiodvalue - PulseWidth)
13165  if Remainder <= 0:
13166  Remainder = 1
13167  PulseWidth = PulseWidth - SlopeValue
13168  if PulseWidth <=0:
13169  PulseWidth = 1
13170  StepValue = (MaxV - MinV) / SlopeValue
13171  SampleValue = MinV
13172  for i in range(SlopeValue):
13173  AWGBwaveform.append(SampleValue)
13174  SampleValue = SampleValue + StepValue
13175  for i in range(PulseWidth):
13176  AWGBwaveform.append(MaxV)
13177  for i in range(Remainder):
13178  AWGBwaveform.append(MinV)
13179  if AWGBBurstFlag.get() == 1:
13180  TempOneCycle = AWGBwaveform
13181  for i in range(AWGBCycles-1):
13182  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13183  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13184  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
13186  duty2lab.config(text="%")
13187  phaseblab.config(text = "Slope Time")
13188  UpdateAwgCont()
13189 #
13190 def AWGBMakeUpDownRamp():
13191  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
13192  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
13193  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13194  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13195  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13196  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13197 
13198  BAWGBAmpl(0)
13199  BAWGBOffset(0)
13200  BAWGBFreq(0)
13201  BAWGBPhase(0)
13202  BAWGBDutyCycle(0)
13203 
13204  if AWGBFreqvalue > 0.0:
13205  if AWG_2X.get() == 2:
13206  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13207  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13208  else:
13209  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13210  SamplesPermS = int(BaseSampleRate/1000) # 100
13211  else:
13212  AWGBperiodvalue = 0.0
13213  if AWG_Amp_Mode.get() == 1:
13214  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13215  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13216  else:
13217  MaxV = AWGBOffsetvalue
13218  MinV = AWGBAmplvalue
13219  #
13220  if AWGBPhaseDelay.get() == 0:
13221  if AWGBPhasevalue > 0:
13222  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
13223  else:
13224  AWGBdelayvalue = 0.0
13225  elif AWGBPhaseDelay.get() == 1:
13226  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
13227  #
13228  AWGBwaveform = []
13229  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
13230  if PulseWidth <=0:
13231  PulseWidth = 1
13232  Remainder = int(AWGBperiodvalue - PulseWidth)
13233  if Remainder <= 0:
13234  Remainder = 1
13235  UpStepValue = (MaxV - MinV) / PulseWidth
13236  DownStepValue = (MaxV - MinV) / Remainder
13237  SampleValue = MinV
13238  for i in range(PulseWidth):
13239  AWGBwaveform.append(SampleValue)
13240  SampleValue = SampleValue + UpStepValue
13241  for i in range(Remainder):
13242  AWGBwaveform.append(SampleValue)
13243  SampleValue = SampleValue - DownStepValue
13244  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
13245  if AWGBBurstFlag.get() == 1:
13246  TempOneCycle = AWGBwaveform
13247  for i in range(AWGBCycles-1):
13248  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13249  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13250  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
13252  BAWGBPhaseDelay()
13253  duty2lab.config(text = "Symmetry")
13254  BAWGBPhaseDelay()
13255  UpdateAwgCont()
13256 #
13257 def AWGBMakeImpulse():
13258  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
13259  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
13260  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13261  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13262  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13263  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13264 
13265  BAWGBAmpl(0)
13266  BAWGBOffset(0)
13267  BAWGBFreq(0)
13268  BAWGBPhase(0)
13269  BAWGBDutyCycle(0)
13270 
13271  if AWGBFreqvalue > 0.0:
13272  if AWG_2X.get() == 2:
13273  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13274  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13275  else:
13276  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13277  SamplesPermS = int(BaseSampleRate/1000) # 100
13278  else:
13279  AWGBperiodvalue = 0.0
13280  if AWG_Amp_Mode.get() == 1:
13281  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13282  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13283  else:
13284  MaxV = AWGBOffsetvalue
13285  MinV = AWGBAmplvalue
13286  AWGBwaveform = []
13287  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue / 2)
13288  if AWGBPhaseDelay.get() == 0:
13289  DelayValue = int(AWGBperiodvalue*(AWGBPhasevalue/360))
13290  elif AWGBPhaseDelay.get() == 1:
13291  DelayValue = int(AWGBPhasevalue*SamplesPermS)
13292  for i in range(DelayValue-PulseWidth):
13293  AWGBwaveform.append((MinV+MaxV)/2)
13294  for i in range(PulseWidth):
13295  AWGBwaveform.append(MaxV)
13296  for i in range(PulseWidth):
13297  AWGBwaveform.append(MinV)
13298  DelayValue = int(AWGBperiodvalue-DelayValue)
13299  for i in range(DelayValue-PulseWidth):
13300  AWGBwaveform.append((MinV+MaxV)/2)
13301  if AWGBBurstFlag.get() == 1:
13302  TempOneCycle = AWGBwaveform
13303  for i in range(AWGBCycles-1):
13304  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13305  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13306  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
13308  duty2lab.config(text = "Duty Cycle")
13309  BAWGBPhaseDelay()
13310  UpdateAwgCont()
13311 
13312 def AWGBMakeUUNoise():
13313  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
13314  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13315  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13316  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13317  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13318 
13319  BAWGBAmpl(0)
13320  BAWGBOffset(0)
13321  BAWGBFreq(0)
13322 
13323  if AWGBFreqvalue > 0.0:
13324  if AWG_2X.get() == 2:
13325  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13326  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13327  else:
13328  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13329  SamplesPermS = int(BaseSampleRate/1000) # 100
13330  else:
13331  AWGBperiodvalue = 0.0
13332 
13333  if AWGBAmplvalue > AWGBOffsetvalue:
13334  MinV = AWGBOffsetvalue
13335  MaxV = AWGBAmplvalue
13336  else:
13337  MaxV = AWGBOffsetvalue
13338  MinV = AWGBAmplvalue
13339  if AWG_Amp_Mode.get() == 1:
13340  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13341  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13342  AWGBwaveform = []
13343  AWGBwaveform = numpy.random.uniform(MinV, MaxV, int(AWGBperiodvalue))
13344  Mid = (MaxV+MinV)/2
13345  if AWGBBurstFlag.get() == 1:
13346  TempOneCycle = AWGBwaveform
13347  for i in range(AWGBCycles-1):
13348  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13349  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13350  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
13352  BAWGBPhaseDelay()
13353  UpdateAwgCont()
13354 
13355 def AWGBMakeUGNoise():
13356  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
13357  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13358  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13359  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13360  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13361 
13362  BAWGBAmpl(0)
13363  BAWGBOffset(0)
13364  BAWGBFreq(0)
13365 
13366  if AWGBFreqvalue > 0.0:
13367  if AWG_2X.get() == 2:
13368  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13369  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13370  else:
13371  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13372  SamplesPermS = int(BaseSampleRate/1000) # 100
13373  else:
13374  AWGBperiodvalue = 0.0
13375  if AWGBAmplvalue > AWGBOffsetvalue:
13376  MinV = AWGBOffsetvalue
13377  MaxV = AWGBAmplvalue
13378  else:
13379  MaxV = AWGBOffsetvalue
13380  MinV = AWGBAmplvalue
13381  if AWG_Amp_Mode.get() == 1:
13382  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13383  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13384  AWGBwaveform = []
13385  AWGBwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGBperiodvalue))
13386  Mid = (MaxV+MinV)/2
13387  if AWGBBurstFlag.get() == 1:
13388  TempOneCycle = AWGBwaveform
13389  for i in range(AWGBCycles-1):
13390  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13391  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13392  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
13394  BAWGBPhaseDelay()
13395  UpdateAwgCont()
13396 
13397 def BAWGBModeLabel():
13398  global AWGBMode, AWGBIOMode, AWGBModeLabel, DevID, devx, DevOne, CHB, HWRevOne
13399  global EnableScopeOnly
13400 
13401  if AWGBMode.get() == 0: # Source Voltage measure current mode
13402  label_txt = "SVMI"
13403  elif AWGBMode.get() == 1: # Source current measure voltage mode
13404  label_txt = "SIMV"
13405  elif AWGBMode.get() == 2: # High impedance mode
13406  label_txt = "Hi-Z"
13407  if AWGBIOMode.get() > 0: # Split Input / Output mode
13408  if HWRevOne == "D":
13409  if AWGBMode.get() == 0:
13410  AWGBMode.set(1)
13411  CHB.set_mode('i') # channel must be in source current mode for rev D boards
13412  label_txt = "SIMV"
13413  label_txt = label_txt + " Split I/O"
13414  if EnableScopeOnly == 0:
13415  label_txt = label_txt + " Mode"
13416  AWGBModeLabel.config(text = label_txt ) # change displayed value
13417  ReMakeAWGwaves()
13418  #UpdateAwgCont()
13419 
13420 def UpdateAWGB():
13421  global AWGBAmplvalue, AWGBOffsetvalue, AWGA2X, AWG_2X
13422  global AWGBFreqvalue, AWGBPhasevalue, AWGBPhaseDelay
13423  global AWGBDutyCyclevalue, FSweepMode, AWGBRepeatFlag, AWGSync
13424  global AWGBWave, AWGBMode, AWGBTerm, AWGBwaveform, AWGBIOMode
13425  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne
13426  global amp2lab, off2lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13427  global AWGA2X, AWGB2X, AWGAWave, AWGARepeatFlag, EnableScopeOnly
13428  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13429 
13430  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
13431  amp2lab.config(text = "Min Ch B" ) # change displayed value
13432  off2lab.config(text = "Max Ch B" ) # change displayed value
13433  else:
13434  amp2lab.config(text = "Amp Ch B" )
13435  off2lab.config(text = "Off Ch B" )
13436 #
13437  if AWG_2X.get() == 1:
13438  AWGBWave = 'arbitrary'
13439  if AWGBFreqvalue > 0.0:
13440  AWGBperiodvalue = AWGSAMPLErate/AWGBFreqvalue
13441  else:
13442  AWGBperiodvalue = 0.0
13443 #
13444  if AWGBPhaseDelay.get() == 0:
13445  if AWGBWave == 'square':
13446  AWGBPhasevalue = AWGBPhasevalue + 270.0
13447  if AWGBPhasevalue > 359:
13448  AWGBPhasevalue = AWGBPhasevalue - 360
13449  if AWGBPhasevalue > 0:
13450  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
13451  else:
13452  AWGBdelayvalue = 0.0
13453  elif AWGBPhaseDelay.get() == 1:
13454  AWGBdelayvalue = AWGBPhasevalue * 100
13455 #
13456  if AWGBTerm.get() == 0: # Open termination
13457  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
13458  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
13459  elif AWGBTerm.get() == 1: # 50 Ohm termination to GND
13460  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
13461  devx.ctrl_transfer( 0x40, 0x50, 38, 0, 0, 0, 100) # set GND switch to closed
13462  elif AWGBTerm.get() == 2: # 50 Ohm termination to +2.5 Volts
13463  devx.ctrl_transfer( 0x40, 0x50, 37, 0, 0, 0, 100) # set 2.5 V switch to closed
13464  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
13465 
13466  if AWGBWave == 'dc':
13467  if AWG_2X.get() == 1:
13468  AWGBWave == 'arbitrary'
13469  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
13470  else:
13471  if AWGBMode.get() == 0: # Source Voltage measure current mode
13472  if AWGBIOMode.get() == 0:
13473  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
13474  else:
13475  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
13476  CHB.constant(AWGBOffsetvalue)
13477  if AWGBMode.get() == 1: # Source current measure Voltage mode
13478  if AWGBIOMode.get() == 0:
13479  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
13480  else:
13481  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
13482  CHB.constant(AWGBOffsetvalue/1000)
13483  if AWGBMode.get() == 2: # Hi impedance mode
13484  if AWGBIOMode.get() == 0:
13485  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
13486  else:
13487  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
13488 #
13489  if AWGBIOMode.get() > 0: # Split Input / Output mode
13490  if HWRevOne == "D":
13491  AWGBMode.set(1)
13492  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
13493 #
13494  else:
13495  if AWGBMode.get() == 0: # Source Voltage measure current mode
13496  if AWGBIOMode.get() == 0:
13497  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
13498  else:
13499  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
13500  if AWGBMode.get() == 1: # Source current measure Voltage mode
13501  if AWGBIOMode.get() == 0:
13502  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
13503  else:
13504  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
13505  AWGBOffsetvalue = AWGBOffsetvalue/1000
13506  AWGBAmplvalue = AWGBAmplvalue/1000
13507  if AWGBMode.get() == 2: # Hi impedance mode
13508  if AWGBIOMode.get() == 0:
13509  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
13510  else:
13511  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
13512  else:
13513  if AWG_Amp_Mode.get() == 1:
13514  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13515  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13516  else:
13517  MaxV = AWGBOffsetvalue
13518  MinV = AWGBAmplvalue
13519  try: # keep going even if low level library returns an error
13520  if AWGBWave == 'sine':
13521  CHB.sine(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
13522  elif AWGBWave == 'triangle':
13523  CHB.triangle(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
13524  elif AWGBWave == 'sawtooth':
13525  CHB.sawtooth(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
13526  elif AWGBWave == 'square':
13527  CHB.square(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue, AWGBDutyCyclevalue)
13528  elif AWGBWave == 'stairstep':
13529  CHB.stairstep(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
13530  elif AWGBWave == 'arbitrary':
13531  if EnableScopeOnly == 0:
13532  AddAWGBNoise()
13533  if AWGSync.get() == 0:
13534  AWGBRepeatFlag.set(1)
13535  if AWG_2X.get() == 1:
13536  AWGBWave == 'arbitrary'
13537  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
13538  else:
13539  CHB.arbitrary(AWGBwaveform, AWGBRepeatFlag.get()) # set repeat flag
13540  except:
13541  donothing()
13542  if AWGBIOMode.get() > 0: # Split Input / Output mode
13543  if HWRevOne == "D":
13544  AWGBMode.set(1)
13545  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
13546 #
13547 def AddAWGBNoise():
13548  global AWG_2X, AWGA2X, AWGBwaveform
13549  global AWGBNoiseEntry, AWGBsbnoise, AWGBNoisevalue
13550 
13551  if AWGBsbnoise.get() == "None":
13552  return
13553  else:
13554  try:
13555  AWGBNoisevalue = float(eval(AWGBNoiseEntry.get()))
13556  except:
13557  AWGBNoiseEntry.delete(0,"end")
13558  AWGBNoiseEntry.insert(0, AWGBNoisevalue)
13559  if AWGBNoisevalue == 0.0:
13560  return
13561  AWGBNoiseform = []
13562  if AWGBsbnoise.get() == "Gaussian":
13563  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGBwaveform))
13564  else:
13565  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGBwaveform))
13566  AWGBwaveform = AWGBwaveform + AWGBNoiseform
13567  if AWG_2X.get() == 2:
13568  if AWGBsbnoise.get() == "Gaussian":
13569  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGA2X))
13570  else:
13571  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGA2X))
13572  AWGA2X = AWGA2X + AWGBNoiseform
13573 #
13574 def UpdateAwgCont():
13575  global session, CHA, CHB, AWGSync
13576  # if running and in continuous streaming mode temp stop, flush buffer and restart to change AWG settings
13577  if (RUNstatus.get() == 1) and AWGSync.get() == 0:
13578  if session.continuous:
13579  session.end()
13580  BAWGEnab() # set-up new AWG settings
13581  time.sleep(0.01) # wait awhile here for some reason
13582  session.start(0)
13583 #
13584 def UpdateAwgContRet(temp):
13585  ReMakeAWGwaves()
13586 
13587 def BAWGEnab():
13588  global AWGAMode, AWGBMode, AWGSync
13589  global CHA, CHB, discontloop, contloop, session
13590 
13591  # Stream = False
13592  # print "Updateing AWGs"
13593  BAWGAAmpl(0)
13594  BAWGAOffset(0)
13595  BAWGAFreq(0)
13596  BAWGAPhase(0)
13597  BAWGADutyCycle(0)
13598  BAWGAShape()
13599  BAWGBAmpl(0)
13600  BAWGBOffset(0)
13601  BAWGBFreq(0)
13602  BAWGBPhase(0)
13603  BAWGBDutyCycle(0)
13604  BAWGBShape()
13605  UpdateAWGA()
13606  UpdateAWGB()
13607 
13608 def BAWGSync():
13609  global RUNstatus, AWGSync, session, CHA, CHB, IAScreenStatus, IADisp
13610 
13611  if (RUNstatus.get() == 1): # do this only if running
13612  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
13613  AWGSync.set(1)
13614  return
13615  if AWGSync.get() == 0:
13616  #UpdateAwgCont()
13617  session.flush()
13618  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
13619  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
13620  BAWGEnab()
13621  session.start(0)
13622  time.sleep(0.02) # wait awhile here for some reason
13623  elif session.continuous:
13624  session.end()
13625  session.flush()
13626  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
13627  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
13628 
13629 # ======= Spectrum Analyzer functions ===========
13630 #
13631 def BSaveScreenSA():
13632  global CANVASwidthF, CANVASheightF, freqwindow
13633  global COLORtext
13634  # ask for file name
13635  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=freqwindow)
13636  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=freqwindow)
13637  if MarkerNum > 0 or ColorMode.get() > 0:
13638  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
13639  else: # temp change text color to black
13640  COLORtext = "#000000"
13642  # save postscript file
13643  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
13644  #
13645  COLORtext = "#ffffff"
13647 #
13648 def Bnot():
13649  print( "Routine not made yet")
13650 
13651 def BShowCurvesAllSA():
13652  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
13653  ShowC1_VdB.set(1)
13654  ShowC1_P.set(1)
13655  ShowC2_VdB.set(1)
13656  ShowC2_P.set(1)
13657 
13658 def BShowCurvesNoneSA():
13659  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
13660  ShowC1_VdB.set(0)
13661  ShowC1_P.set(0)
13662  ShowC2_VdB.set(0)
13663  ShowC2_P.set(0)
13664 
13665 def BNormalmode():
13666  global RUNstatus
13667  global FreqTraceMode
13668 
13669  FreqTraceMode.set(1)
13670  if RUNstatus.get() == 0: # Update if stopped
13672  if RUNstatus.get() == 2: # Restart if running
13673  RUNstatus.set(4)
13674 
13675 def BPeakholdmode():
13676  global RUNstatus
13677  global FreqTraceMode
13678 
13679  FreqTraceMode.set(2)
13680  if RUNstatus.get() == 0: # Update if stopped
13682  if RUNstatus.get() == 2: # Restart if running
13683  RUNstatus.set(4)
13684 
13685 def BAveragemode():
13686  global RUNstatus, TRACEaverage, FreqTraceMode, freqwindow
13687 
13688  FreqTraceMode.set(3)
13689 
13690  if RUNstatus.get() == 0: # Update if stopped
13692  if RUNstatus.get() == 2: # Restart if running
13693  RUNstatus.set(4)
13694 
13695 def BResetFreqAvg():
13696  global FreqTraceMode, TRACEresetFreq
13697 
13698  if FreqTraceMode.get()==3:
13699  TRACEresetFreq = True
13700 
13701 def BSTOREtraceSA():
13702  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
13703  global T1Fline, T2Fline, T1FRline, T2FRline, TFRMline, TFMline
13704  global T1Pline, T2Pline, T1PRline, T2PRline
13705  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13706  global PeakxM, PeakyM, PeakMdb, PeakfreqM
13707  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
13708  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
13709  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
13710 
13711  if ShowC1_VdB.get() == 1:
13712  T1FRline = T1Fline
13713  PeakxRA = PeakxA
13714  PeakyRA = PeakyA
13715  PeakdbRA = PeakdbA
13716  PeakfreqRA = PeakfreqA
13717  if ShowC2_VdB.get() == 1:
13718  T2FRline = T2Fline
13719  PeakxRB = PeakxB
13720  PeakyRB = PeakyB
13721  PeakdbRB = PeakdbB
13722  PeakfreqRB = PeakfreqB
13723  if ShowC1_P.get() == 1:
13724  T1PRline = T1Pline
13725  if ShowC2_P.get() == 1:
13726  T2PRline = T2Pline
13727  if ShowMathSA.get() > 0:
13728  TFRMline = TFMline
13729  PeakxRM = PeakxM
13730  PeakyRM = PeakyM
13731  PeakRMdb = PeakMdb
13732  PeakfreqRM = PeakfreqM
13733 
13734  UpdateFreqTrace() # Always Update
13735 #
13736 def BSTOREtraceBP():
13737  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
13738  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
13739  global TAFline, TBFline, TAFRline, TBFRline, TBPRMline, TBPMline
13740  global TAPline, TBPline, TAPRline, TBPRline
13741  global TIARline, TIAXline, TIAMagline, TIAAngline
13742  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
13743  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13744  global PeakxM, PeakyM, PeakMdb, PeakfreqM
13745  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
13746  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
13747  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
13748 
13749  if ShowCA_VdB.get() == 1:
13750  TAFRline = TAFline
13751  PeakxRA = PeakxA
13752  PeakyRA = PeakyA
13753  PeakdbRA = PeakdbA
13754  PeakfreqRA = PeakfreqA
13755  if ShowCB_VdB.get() == 1:
13756  TBFRline = TBFline
13757  PeakxRB = PeakxB
13758  PeakyRB = PeakyB
13759  PeakdbRB = PeakdbB
13760  PeakfreqRB = PeakfreqB
13761  if ShowCA_P.get() == 1:
13762  TAPRline = TAPline
13763  if ShowCB_P.get() == 1:
13764  TBPRline = TBPline
13765  if ShowMathBP.get() > 0:
13766  TBPRMline = TBPMline
13767  PeakxRM = PeakxM
13768  PeakyRM = PeakyM
13769  PeakRMdb = PeakMdb
13770  PeakfreqRM = PeakfreqM
13771  if Show_Rseries.get() > 0:
13772  RefIARline = TIARline
13773  if Show_Xseries.get() > 0:
13774  RefIAXline = TIAXline
13775  if Show_Magnitude.get() > 0:
13776  RefIAMagline = TIAMagline
13777  if Show_Angle.get() > 0:
13778  RefIAAngline = TIAAngline
13779  UpdateBodeTrace() # Always Update
13780 #
13781 def BCSVfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
13782  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins, bodewindow
13783  global SAMPLErate, ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, TRACEsize
13784 
13785  # Set the TRACEsize variable
13786  if ShowCA_VdB.get() == 1:
13787  TRACEsize = len(FSweepAdB) # Set the trace length
13788  elif ShowCA_VdB.get() == 1:
13789  TRACEsize = len(FSweepBdB)
13790  if TRACEsize == 0: # If no trace, skip rest of this routine
13791  return()
13792 # ask if save as magnitude or dB
13793  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=bodewindow)
13794 # Yes 1 = dB, No 0 = Mag
13795  # Make the file name and open it
13796  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
13797  filename = "Bode-" + tme
13798  filename = filename + ".csv"
13799  # open file to save data
13800  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
13801  filetypes=[("Comma Separated Values", "*.csv")], parent=bodewindow)
13802  DataFile = open(filename,'a') # Open output file
13803  HeaderString = 'Frequency-#, '
13804  if ShowCA_VdB.get() == 1:
13805  if dB == 1:
13806  HeaderString = HeaderString + 'CA-dB, '
13807  if dB == 0:
13808  HeaderString = HeaderString + 'CA-Mag, '
13809  if ShowCB_VdB.get() == 1:
13810  if dB == 1:
13811  HeaderString = HeaderString + 'CB-dB, '
13812  if dB == 0:
13813  HeaderString = HeaderString + 'CB-Mag, '
13814  if ShowCA_P.get() == 1:
13815  HeaderString = HeaderString + 'Phase A-B, '
13816  if ShowCB_P.get() == 1:
13817  HeaderString = HeaderString + 'Phase B-A, '
13818  HeaderString = HeaderString + '\n'
13819  DataFile.write( HeaderString )
13820 
13821  n = 0
13822  while n < len(FSweepAdB):
13823  F = FBins[FStep[n]] # look up frequency bin in list of bins
13824  txt = str(F)
13825  if ShowCA_VdB.get() == 1:
13826  V = 10 * math.log10(float(FSweepAdB[n]))
13827  if dB == 0:
13828  V = 10.0**(V/20.0)
13829  txt = txt + "," + str(V)
13830  if ShowCB_VdB.get() == 1:
13831  V = 10 * math.log10(float(FSweepBdB[n]))
13832  if dB == 0:
13833  V = 10.0**(V/20.0)
13834  txt = txt + "," + str(V)
13835  if ShowCA_P.get() == 1:
13836  RelPhase = FSweepAPh[n]#-FSweepBPh[n]
13837  if RelPhase > 180:
13838  RelPhase = RelPhase - 360
13839  elif RelPhase < -180:
13840  RelPhase = RelPhase + 360
13841  txt = txt + "," + str(RelPhase)
13842  if ShowCB_P.get() == 1:
13843  RelPhase = FSweepBPh[n]#-FSweepAPh[n]
13844  if RelPhase > 180:
13845  RelPhase = RelPhase - 360
13846  elif RelPhase < -180:
13847  RelPhase = RelPhase + 360
13848  txt = txt + "," + str(RelPhase)
13849  txt = txt + "\n"
13850  DataFile.write(txt)
13851  n = n + 1
13852 
13853  DataFile.close() # Close the file
13854 
13855 def BSaveDataIA():
13856  global iawindow, FStep, FBins
13857  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
13858 
13859  if NetworkScreenStatus.get() > 0:
13860  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
13861  filename = "Impedance-" + tme
13862  filename = filename + ".csv"
13863  # open file to save data
13864  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
13865  filetypes=[("Comma Separated Values", "*.csv")], parent=iawindow)
13866  DataFile = open(filename,'a') # Open output file
13867  HeaderString = 'Frequency, Series R, Series X, Series Z, Series Angle'
13868  HeaderString = HeaderString + '\n'
13869  DataFile.write( HeaderString )
13870 
13871  n = 0
13872  while n < len(NSweepSeriesR):
13873  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
13874  txt = str(F) + "," + str(NSweepSeriesR[n]) + "," + str(NSweepSeriesX[n]) + "," + str(NSweepSeriesMag[n]) + "," + str(NSweepSeriesAng[n])
13875  txt = txt + "\n"
13876  DataFile.write(txt)
13877  n = n + 1
13878  DataFile.close() # Close the file
13879  else:
13880  return
13881 #
13882 def BStartSA():
13883  global RUNstatus, PowerStatus, devx, PwrBt, freqwindow, session, AWGSync, contloop, discontloop
13884  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA, DevID, FWRevOne, StopFreqEntry
13885  global Two_X_Sample, ADC_Mux_Mode, ShowAWGASA, ShowAWGBSA
13886 
13887  #AWGSync.set(0) # always run in continuous mode
13888  if DevID == "No Device":
13889  showwarning("WARNING","No Device Plugged In!")
13890  elif FWRevOne == 0.0:
13891  showwarning("WARNING","Out of data Firmware!")
13892  else:
13893  if PowerStatus == 0:
13894  PowerStatus = 1
13895  PwrBt.config(style="Pwr.TButton",text="PWR-On")
13896  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
13897 
13898  if (ShowC1_VdB.get() == 0 and
13899  ShowC2_VdB.get() == 0 and
13900  ShowMathSA.get() == 0 and
13901  ShowAWGASA.get() == 0 and
13902  ShowAWGBSA.get() == 0 and
13903  ShowC1_P.get() == 0 and
13904  ShowC2_P.get() == 0):
13905  showwarning("WARNING","Select at least one trace first", parent=freqwindow)
13906  return()
13907  try:
13908  StopFrequency = float(StopFreqEntry.get())
13909  except:
13910  StopFreqEntry.delete(0,"end")
13911  StopFreqEntry.insert(0,50000)
13912  StopFrequency = 50000
13913  if FWRevOne > 2.16:
13914  if StopFrequency >= 50000:
13915  Two_X_Sample.set(1)
13916  else:
13917  Two_X_Sample.set(0)
13918  ADC_Mux_Mode.set(0)
13919  SetADC_Mux()
13920  #
13921  BStart()
13922 #
13923  UpdateFreqAll() # Always Update
13924 
13925 def BStopSA():
13926  global RUNstatus, session, AWGSync
13927 
13928  if (RUNstatus.get() == 1):
13929  RUNstatus.set(0)
13930  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
13931  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
13932  if AWGSync.get() == 0: # running in continuous mode
13933  CHA.constant(0.0)
13934  CHB.constant(0.0)
13935  # print "Stoping continuous mode"
13936  if session.continuous:
13937  # print "Stoping Is Continuous? ", session.continuous
13938  time.sleep(0.02)
13939  #print "Is Continuous? ", session.continuous
13940  else:
13941  contloop = 0
13942  discontloop = 1
13943  session.cancel()
13944  elif (RUNstatus.get() == 2):
13945  RUNstatus.set(3)
13946  elif (RUNstatus.get() == 3):
13947  RUNstatus.set(3)
13948  elif (RUNstatus.get() == 4):
13949  RUNstatus.set(3)
13950  UpdateFreqAll() # Always Update
13951 
13952 def Blevel1():
13953  global DBlevel
13954  global RUNstatus
13955 
13956  DBlevel.set(DBlevel.get() - 1)
13957 
13958  if RUNstatus.get() == 0: # Update if stopped
13959  UpdateFreqTrace()
13960 
13961 def Blevel2():
13962  global DBlevel
13963  global RUNstatus
13964 
13965  DBlevel.set(DBlevel.get() + 1)
13966 
13967  if RUNstatus.get() == 0: # Update if stopped
13968  UpdateFreqTrace()
13969 
13970 def Blevel3():
13971  global DBlevel
13972  global RUNstatus
13973 
13974  DBlevel.set(DBlevel.get() - 10)
13975 
13976  if RUNstatus.get() == 0: # Update if stopped
13977  UpdateFreqTrace()
13978 
13979 def Blevel4():
13980  global DBlevel
13981  global RUNstatus
13982 
13983  DBlevel.set(DBlevel.get() + 10)
13984 
13985  if RUNstatus.get() == 0: # Update if stopped
13986  UpdateFreqTrace()
13987 #
13988 def Bsamples1():
13989  global RUNstatus, SpectrumScreenStatus, IAScreenStatus
13990  global SMPfftpwrTwo, SMPfft, FFTwindow
13991  global TRACEresetFreq, PhAScreenStatus
13992 
13993  if FFTwindow.get() != 8:
13994  if (SMPfftpwrTwo.get() > 6): # Min 64
13995  SMPfftpwrTwo.set(SMPfftpwrTwo.get() - 1)
13996  TRACEresetFreq = True # Reset trace peak and trace average
13997  SMPfft = 2 ** int(SMPfftpwrTwo.get())
13998 
13999  if RUNstatus.get() == 0: # Update if stopped
14000  if SpectrumScreenStatus.get() > 0:
14002  if IAScreenStatus.get() > 0:
14003  UpdateIAScreen()
14004  if PhAScreenStatus.get() > 0:
14005  UpdatePhAScreen()
14006  if RUNstatus.get() == 2: # Restart if running
14007  RUNstatus.set(4)
14008 
14009 def Bsamples2():
14010  global RUNstatus, PhAScreenStatus
14011  global SMPfftpwrTwo, SMPfft, FFTwindow
14012  global TRACEresetFreq, SpectrumScreenStatus, IAScreenStatus
14013 
14014  if FFTwindow.get() != 8:
14015  if (SMPfftpwrTwo.get() < 16): # Max 65536
14016  SMPfftpwrTwo.set(SMPfftpwrTwo.get() + 1)
14017  TRACEresetFREQ = True # Reset trace peak and trace average
14018  SMPfft = 2 ** int(SMPfftpwrTwo.get())
14019 
14020  if RUNstatus.get() == 0: # Update if stopped
14021  if SpectrumScreenStatus.get() > 0:
14023  if IAScreenStatus.get() > 0:
14024  UpdateIAScreen()
14025  if PhAScreenStatus.get() > 0:
14026  UpdatePhAScreen()
14027  if RUNstatus.get() == 2: # Restart if running
14028  RUNstatus.set(4)
14029 
14030 def BDBdiv1():
14031  global DBdivindex
14032  global RUNstatus
14033 
14034  if (DBdivindex.get() >= 1):
14035  DBdivindex.set(DBdivindex.get() - 1)
14036 
14037  if RUNstatus.get() == 0: # Update if stopped
14038  UpdateFreqTrace()
14039 
14040 def BDBdiv2():
14041  global DBdivindex
14042  global DBdivlist
14043  global RUNstatus
14044 
14045  if (DBdivindex.get() < len(DBdivlist) - 1):
14046  DBdivindex.set(DBdivindex.get() + 1)
14047 
14048  if RUNstatus.get() == 0: # Update if stopped
14049  UpdateFreqTrace()
14050 #----- Bode Plot controls
14051 def BStartBP():
14052  global RUNstatus, LoopNum, PowerStatus, devx, PwrBt, bodewindow, session, AWGSync
14053  global ShowCA_VdB, ShowCB_P, ShowCB_VdB, ShowCB_P, ShowMathBP, contloop, discontloop
14054  global FBins, FStep, NSteps, FSweepMode, HScaleBP, CutDC
14055  global AWGAMode, AWGAShape, AWGBMode, AWGBShape
14056  global StartBodeEntry, StopBodeEntry, SweepStepBodeEntry, DevID, FWRevOne
14057  global AWGAFreqEntry, AWGBFreqEntry, Reset_Freq, AWGAIOMode, AWGBIOMode
14058  global Two_X_Sample, ADC_Mux_Mode, AWG_2X, ZEROstuffing, SAMPLErate
14059  global BeginIndex, EndIndex
14060 
14061  if DevID == "No Device":
14062  showwarning("WARNING","No Device Plugged In!")
14063  elif FWRevOne == 0.0:
14064  showwarning("WARNING","Out of data Firmware!")
14065  else:
14066  if PowerStatus == 0:
14067  PowerStatus = 1
14068  PwrBt.config(style="Pwr.TButton",text="PWR-On")
14069  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
14070 
14071  if ShowCA_VdB.get() == 0 and ShowCB_VdB.get() == 0 and ShowMathBP.get() == 0:
14072  showwarning("WARNING","Select at least one trace first", parent=bodewindow)
14073  return()
14074  #
14075  if ZEROstuffing.get() < 3:
14076  ZEROstuffing.set(3)
14077  CutDC.set(1) # set to remove DC
14078  try:
14079  EndFreq = float(StopBodeEntry.get())
14080  except:
14081  StopBodeEntry.delete(0,"end")
14082  StopBodeEntry.insert(0,10000)
14083  EndFreq = 10000
14084  if FWRevOne > 2.16:
14085  if EndFreq >= 20000:
14086  Two_X_Sample.set(1)
14087  FBins = numpy.linspace(0, 100000, num=32768) #16384)
14088  else:
14089  Two_X_Sample.set(0)
14090  FBins = numpy.linspace(0, 50000, num=32768) #16384)
14091  ADC_Mux_Mode.set(0)
14092  SetADC_Mux()
14093  try:
14094  BeginFreq = float(StartBodeEntry.get())
14095  except:
14096  StartBodeEntry.delete(0,"end")
14097  StartBodeEntry.insert(0,100)
14098  BeginFreq = 100
14099  #
14100  if FSweepMode.get() == 1:
14101  if AWGAMode.get() == 2:
14102  AWGAMode.set(0) # Set AWG A to SVMI
14103  AWGAShape.set(18) # Set Shape to Sine
14104  if Two_X_Sample.get() == 1:
14105  AWGBIOMode.set(1)
14106  AWGBMode.set(0)
14107  else:
14108  AWGBMode.set(2) # Set AWG B to Hi-Z
14109  AWG_2X.set(0)
14110  BAWG2X()
14111  Reset_Freq = AWGAFreqEntry.get()
14112  if FSweepMode.get() == 2:
14113  if AWGBMode.get() == 2:
14114  AWGBMode.set(0) # Set AWG B to SVMI
14115  AWGBShape.set(18) # Set Shape to Sine
14116  if Two_X_Sample.get() == 1:
14117  AWGAIOMode.set(1)
14118  AWGAMode.set(0)
14119  else:
14120  AWGAMode.set(2) # Set AWG A to Hi-Z
14121  AWG_2X.set(0)
14122  BAWG2X()
14123  Reset_Freq = AWGBFreqEntry.get()
14124  if FSweepMode.get() == 3: # using external Minigen
14125  AWGAMode.set(2) # Set AWG A to Hi-Z
14126  AWGBMode.set(2) # Set AWG B to Hi-Z
14127  try:
14128  NSteps.set(float(SweepStepBodeEntry.get()))
14129  except:
14130  SweepStepBodeEntry.delete(0,"end")
14131  SweepStepBodeEntry.insert(0, NSteps.get())
14132  #
14133  if FSweepMode.get() > 0:
14134  BAWGAModeLabel() # make sure AWG screen labels reflect any changes to the modes
14135  BAWGBModeLabel()
14136  LoopNum.set(1)
14137  NyquistFreq = SAMPLErate/2
14138  BeginIndex = int((BeginFreq/NyquistFreq)*32768)#16384)
14139  EndIndex = int((EndFreq/NyquistFreq)*32768)#16384)
14140  if NSteps.get() < 5:
14141  NSteps.set(5)
14142  if HScaleBP.get() == 1:
14143  LogFStop = math.log10(EndIndex)
14144  try:
14145  LogFStart = math.log10(BeginIndex)
14146  except:
14147  LogFStart = 0.1
14148  FStep = numpy.logspace(LogFStart, LogFStop, num=NSteps.get(), base=10.0)
14149  else:
14150  FStep = numpy.linspace(BeginIndex, EndIndex, num=NSteps.get())
14151 
14152  BStart()
14153  # UpdateBodeAll() # Always Update
14154 #
14155 def BStopBP():
14156  global RUNstatus, session, AWGSync, FSweepMode, AWGAFreqEntry, AWGBFreqEntry, Reset_Freq
14157 
14158  if FSweepMode.get() == 1:
14159  AWGAFreqEntry.delete(0,"end")
14160  AWGAFreqEntry.insert(0, Reset_Freq)
14161  if FSweepMode.get() == 2:
14162  AWGBFreqEntry.delete(0,"end")
14163  AWGBFreqEntry.insert(0, Reset_Freq)
14164 #
14165  if (RUNstatus.get() == 1):
14166  RUNstatus.set(0)
14167  if AWGSync.get() == 0: # running in continuous mode
14168  session.cancel() # cancel continuous session mode while paused
14169  elif (RUNstatus.get() == 2):
14170  RUNstatus.set(3)
14171  elif (RUNstatus.get() == 3):
14172  RUNstatus.set(3)
14173  elif (RUNstatus.get() == 4):
14174  RUNstatus.set(3)
14175  UpdateBodeAll() # Always Update
14176 #
14177 def Blevel1BP():
14178  global DBlevelBP
14179  global RUNstatus
14180 
14181  DBlevelBP.set(DBlevelBP.get() - 1)
14182 
14183  if RUNstatus.get() == 0: # Update if stopped
14184  UpdateBodeTrace()
14185 
14186 def Blevel2BP():
14187  global DBlevelBP
14188  global RUNstatus
14189 
14190  DBlevelBP.set(DBlevelBP.get() + 1)
14191 
14192  if RUNstatus.get() == 0: # Update if stopped
14193  UpdateBodeTrace()
14194 
14195 def Blevel3BP():
14196  global DBlevelBP
14197  global RUNstatus
14198 
14199  DBlevelBP.set(DBlevelBP.get() - 10)
14200 
14201  if RUNstatus.get() == 0: # Update if stopped
14202  UpdateBodeTrace()
14203 
14204 def Blevel4BP():
14205  global DBlevelBP
14206  global RUNstatus
14207 
14208  DBlevelBP.set(DBlevelBP.get() + 10)
14209 
14210  if RUNstatus.get() == 0: # Update if stopped
14211  UpdateBodeTrace()
14212 
14213 def BDBdiv1BP():
14214  global DBdivindexBP
14215  global RUNstatus
14216 
14217  if (DBdivindexBP.get() >= 1):
14218  DBdivindexBP.set(DBdivindexBP.get() - 1)
14219 
14220  if RUNstatus.get() == 0: # Update if stopped
14221  UpdateBodeTrace()
14222 
14223 def BDBdiv2BP():
14224  global DBdivindexBP
14225  global DBdivlist
14226  global RUNstatus
14227 
14228  if (DBdivindexBP.get() < len(DBdivlist) - 1):
14229  DBdivindexBP.set(DBdivindexBP.get() + 1)
14230 
14231  if RUNstatus.get() == 0: # Update if stopped
14232  UpdateBodeTrace()
14233 #
14234 def BShowCurvesAllBP():
14235  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
14236  ShowCA_VdB.set(1)
14237  ShowCA_P.set(1)
14238  ShowCB_VdB.set(1)
14239  ShowCB_P.set(1)
14240 
14241 def BShowCurvesNoneBP():
14242  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
14243  ShowCA_VdB.set(0)
14244  ShowCA_P.set(0)
14245  ShowCB_VdB.set(0)
14246  ShowCB_P.set(0)
14247 # Bode Plot refresh
14248 def UpdateBodeAll(): # Update Data, trace and screen
14249  global FFTBuffA, FFTBuffB
14250  global SMPfft
14251 
14252  # DoFFT() # Fast Fourier transformation
14253  MakeBodeTrace() # Update the traces
14254  UpdateBodeScreen() # Update the screen
14255 
14256 def UpdateBodeTrace(): # Update trace and screen
14257  MakeBodeTrace() # Update traces
14258  UpdateBodeScreen() # Update the screen
14259 
14260 def UpdateBodeScreen(): # Update screen with trace and text
14261  MakeBodeScreen() # Update the screen
14262 
14263 # ============================================ Freq Main routine ====================================================
14264 
14265 def UpdateFreqAll(): # Update Data, trace and screen
14266  global FFTBuffA, FFTBuffB
14267  global SMPfft
14268 
14269  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
14270  return
14271 
14272  # DoFFT() # Fast Fourier transformation
14273  MakeFreqTrace() # Update the traces
14274  UpdateFreqScreen() # Update the screen
14275 
14276 def UpdateFreqTrace(): # Update trace and screen
14277  MakeFreqTrace() # Update traces
14278  UpdateFreqScreen() # Update the screen
14279 
14280 def UpdateFreqScreen(): # Update screen with trace and text
14281  MakeFreqScreen() # Update the screen
14282 
14283 def DoFFT(): # Fast Fourier transformation
14284  global FFTBuffA, FFTBuffB, AWGAwaveform, AWGBwaveform
14285  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowAWGASA, ShowAWGBSA
14286  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
14287  global FFTmemoryB, FFTresultB, FFTresultAWGA, FFTresultAWGB
14288  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh
14289  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
14290  global FFTwindowshape, FFTbandwidth
14291  global AWGSAMPLErate, StartFreqEntry, StopFreqEntry, StartBodeEntry
14292  global SMPfft, LoopNum, IA_Ext_Conf
14293  global STARTsample, STOPsample, CutDC
14294  global TRACEaverage, FreqTraceMode, FSweepMode
14295  global TRACEresetFreq, ZEROstuffing
14296  global SpectrumScreenStatus, IAScreenStatus, BodeScreenStatus
14297  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
14298  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesL
14299 
14300  # T1 = time.time() # For time measurement of FFT routine
14301  REX = []
14302  PhaseA = []
14303  PhaseB = []
14304  # Convert list to numpy array REX for faster Numpy calculations
14305  # Take the first fft samples
14306  REX = numpy.array(FFTBuffA[0:SMPfft]) # Make a numpy arry of the list
14307 
14308  # Set Analog level display value MAX value is 5 volts for ALM1000
14309  REX = REX / 5.0
14310 
14311  # Do the FFT window function
14312  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
14313 
14314  # Zero stuffing of array for better interpolation of peak level of signals
14315  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14316  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14317 
14318  # Save previous trace in memory for max or average trace
14319  FFTmemoryA = FFTresultA
14320  if FreqTraceMode.get() == 3:
14321  PhaseMemoryA = PhaseA
14322 
14323  # FFT with numpy
14324  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14325  PhaseA = numpy.angle(ALL, deg=True) # calculate angle
14326  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14327  ALL = ALL * ALL # Convert from Voltage to Power (P = (V*V) / R; R = 1)
14328 
14329  le = int(len(ALL) / 2) # Only half is used, other half is mirror
14330  # ALL = ALL[0:le] # So take only first half of the array
14331  FFTresultA = ALL[0:le]
14332  PhaseA = PhaseA[0:le]
14333  RMScorr = 1.0 / SMPfft # For VOLTAGE!
14334  Powcorr = 50*(RMScorr **2) # vpktage squared For POWER!
14335  FFTresultA = FFTresultA * Powcorr
14336 #
14337  REX = []
14338  # Convert list to numpy array REX for faster Numpy calculations
14339  # Take the first fft samples
14340  REX = numpy.array(FFTBuffB[0:SMPfft]) # Make a numpy arry of the list
14341 
14342  # Set level display value MAX value is 5 volts for ALM1000
14343  REX = REX / 5.0
14344 
14345  # Do the FFT window function
14346  try:
14347  REX = REX * FFTwindowshape # The windowing shape function only over the samples
14348  except:
14349  return
14350  # Zero stuffing of array for better interpolation of peak level of signals
14351  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14352  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14353 
14354  # Save previous trace in memory for max or average trace
14355  FFTmemoryB = FFTresultB
14356  if FreqTraceMode.get() == 3:
14357  PhaseMemoryB = PhaseB
14358  # FFT with numpy
14359  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14360  PhaseB = numpy.angle(ALL, deg=True) # calculate angle
14361  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14362  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
14363 
14364  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
14365  # ALL = ALL[0:le] # So take only first half of the array
14366  FFTresultB = ALL[0:le]
14367  PhaseB = PhaseB[0:le]
14368  FFTresultB = FFTresultB * Powcorr
14369 #
14370  if IA_Ext_Conf.get() == 1: # calculate fft for voltage A-B for use if IA set to config 2
14371  REX = []
14372  PhaseAB = []
14373  # Convert list to numpy array REX for faster Numpy calculations
14374  # Take the first fft samples
14375  REX = numpy.array(FFTBuffA[0:SMPfft]-FFTBuffB[0:SMPfft]) # Make a numpy arry of the VA-VB list
14376 
14377  # Set level display value MAX value is 5 volts for ALM1000
14378  REX = REX / 5.0
14379 
14380  # Do the FFT window function
14381  REX = REX * FFTwindowshape # The windowing shape function only over the samples
14382 
14383  # Zero stuffing of array for better interpolation of peak level of signals
14384  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14385  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14386 
14387  # Save previous trace in memory for max or average trace
14388  # FFTmemoryB = FFTresultB
14389  # if FreqTraceMode.get() == 3:
14390  # PhaseMemoryB = PhaseB
14391  # FFT with numpy
14392  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14393  PhaseAB = numpy.angle(ALL, deg=True) # calculate angle
14394  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14395  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
14396 
14397  le = len(ALL) / 2 # Only half is used, other half is mirror
14398  #ALL = ALL[:le] # So take only first half of the array
14399  FFTresultAB = ALL[:le]
14400  PhaseAB = PhaseAB[:le]
14401  FFTresultAB = FFTresultAB * Powcorr
14402 #
14403  if ShowAWGASA.get() > 0:
14404  FFTAWGA = AWGAwaveform
14405  DCA = 0.0
14406  if CutDC.get() == 1:
14407  DCA = numpy.average(FFTAWGA)
14408  FFTAWGA = FFTAWGA - DCA
14409  if len(AWGAwaveform) < SMPfft:
14410  Repeats = math.ceil(SMPfft/len(AWGAwaveform))
14411  i = 0
14412  while i < Repeats:
14413  FFTAWGA = numpy.concatenate((FFTAWGA, AWGAwaveform-DCA))
14414  i = i + 1
14415  REX = []
14416  # Convert list to numpy array REX for faster Numpy calculations
14417  # Take the first fft samples
14418  REX = numpy.array(FFTAWGA[0:SMPfft]) # Make a numpy arry of the list
14419 
14420  # Set level display value MAX value is 5 volts for ALM1000
14421  REX = REX / 5.0
14422 
14423  # Do the FFT window function
14424  try:
14425  REX = REX * FFTwindowshape # The windowing shape function only over the samples
14426  except:
14427  return
14428  # Zero stuffing of array for better interpolation of peak level of signals
14429  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14430  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14431  # FFT with numpy
14432  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14433  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
14434  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14435  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
14436 
14437  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
14438  # ALL = ALL[0:le] # So take only first half of the array
14439  FFTresultAWGA = ALL[0:le]
14440  #PhaseB = PhaseB[0:le]
14441  FFTresultAWGA = FFTresultAWGA * Powcorr
14442 #
14443  if ShowAWGBSA.get() > 0:
14444  FFTAWGB = AWGBwaveform
14445  DCB = 0.0
14446  if CutDC.get() == 1:
14447  DCB = numpy.average(FFTAWGB)
14448  FFTAWGB = FFTAWGB - DCB
14449  if len(AWGBwaveform) < SMPfft:
14450  Repeats = math.ceil(SMPfft/len(AWGBwaveform))
14451  i = 1
14452  while i < Repeats:
14453  FFTAWGB = numpy.concatenate((FFTAWGB, AWGBwaveform-DCB))
14454  i = i + 1
14455  REX = []
14456  # Convert list to numpy array REX for faster Numpy calculations
14457  # Take the first fft samples
14458  REX = numpy.array(FFTAWGB[0:SMPfft]) # Make a numpy arry of the list
14459 
14460  # Set level display value MAX value is 5 volts for ALM1000
14461  REX = REX / 5.0
14462 
14463  # Do the FFT window function
14464  try:
14465  REX = REX * FFTwindowshape # The windowing shape function only over the samples
14466  except:
14467  return
14468  # Zero stuffing of array for better interpolation of peak level of signals
14469  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14470  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14471  # FFT with numpy
14472  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14473  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
14474  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14475  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
14476 
14477  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
14478  #ALL = ALL[0:le] # So take only first half of the array
14479  FFTresultAWGB = ALL[0:le]
14480  #PhaseB = PhaseB[0:le]
14481  FFTresultAWGB = FFTresultAWGB * Powcorr
14482 #
14483  TRACEsize = int(len(FFTresultB))
14484  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
14485  if SpectrumScreenStatus.get() > 0:
14486  try:
14487  StartFrequency = float(StartFreqEntry.get())
14488  except:
14489  StartFreqEntry.delete(0,"end")
14490  StartFreqEntry.insert(0,100)
14491  StartFrequency = 100
14492  STARTsample = int(StartFrequency / Fsample)
14493  else:
14494  STARTsample = 0
14495  if LoopNum.get() == 1:
14496  PhaseMemoryB = PhaseB
14497  FSweepAdB = []
14498  FSweepBdB = []
14499  FSweepAPh = []
14500  FSweepBPh = []
14501  if NetworkScreenStatus.get() > 0:
14502  NSweepSeriesR = []
14503  NSweepSeriesX = []
14504  NSweepSeriesMag = [] # in ohms
14505  NSweepSeriesAng = [] # in degrees
14506  NSweepParallelR = []
14507  NSweepParallelC = []
14508  NSweepParallelL = []
14509  NSweepSeriesC = []
14510  NSweepSeriesL = []
14511  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
14512  if FSweepMode.get() == 1:
14513  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
14514  if ptmax > STARTsample:
14515  STARTsample = ptmax
14516  i = 0
14517  while i < 6:
14518  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
14519  i = i + 1
14520  if FSweepMode.get() == 2:
14521  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
14522  if ptmax > STARTsample:
14523  STARTsample = ptmax
14524  i = 0
14525  while i < 6:
14526  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
14527  i = i + 1
14528 
14529  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
14530  if FSweepMode.get() == 1:
14531  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
14532  if ptmax > STARTsample:
14533  STARTsample = ptmax
14534  i = 0
14535  while i < 6:
14536  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
14537  i = i + 1
14538  if FSweepMode.get() == 2:
14539  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
14540  if ptmax > STARTsample:
14541  STARTsample = ptmax
14542  i = 0
14543  while i < 6:
14544  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
14545  i = i + 1
14546  if len(FFTresultB) == len(FFTmemoryB):
14547  FFTresultB = numpy.maximum(FFTresultB, FFTmemoryB)#
14548  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
14549  try:
14550  FFTresultB = FFTmemoryB + (FFTresultB - FFTmemoryB) / TRACEaverage.get()
14551  PhaseB = PhaseMemoryB +(PhaseB - PhaseMemoryB) / TRACEaverage.get()
14552  except:
14553  FFTmemoryB = FFTresultB
14554  PhaseMemoryB = PhaseB
14555 #
14556  TRACEsize = int(len(FFTresultA))
14557  Fsample = float(AWGSAMPLErate / 2) / (TRACEsize - 1)
14558  if SpectrumScreenStatus.get() > 0:
14559  STARTsample = int(StartFrequency / Fsample)
14560  else:
14561  STARTsample = 0
14562  if LoopNum.get() == 1:
14563  PhaseMemoryA = PhaseA
14564  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
14565  if FSweepMode.get() == 1:
14566  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
14567  if ptmax > STARTsample:
14568  STARTsample = ptmax
14569  i = 0
14570  while i < 6:
14571  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
14572  i = i + 1
14573  if FSweepMode.get() == 2:
14574  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
14575  if ptmax > STARTsample:
14576  STARTsample = ptmax
14577  i = 0
14578  while i < 6:
14579  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
14580  i = i + 1
14581 
14582  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
14583  if FSweepMode.get() == 1:
14584  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
14585  if ptmax > STARTsample:
14586  STARTsample = ptmax
14587  i = 0
14588  while i < 6:
14589  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
14590  i = i + 1
14591  if FSweepMode.get() == 2:
14592  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
14593  if ptmax > STARTsample:
14594  STARTsample = ptmax
14595  i = 0
14596  while i < 6:
14597  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
14598  i = i + 1
14599 #
14600  if len(FFTresultA) == len(FFTmemoryA):
14601  FFTresultA = numpy.maximum(FFTresultA, FFTmemoryA)
14602  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
14603  try:
14604  FFTresultA = FFTmemoryA + (FFTresultA - FFTmemoryA) / TRACEaverage.get()
14605  PhaseA = PhaseMemoryA +(PhaseA - PhaseMemoryA) / TRACEaverage.get()
14606  except:
14607  FFTmemoryA = FFTresultA
14608  PhaseMemoryA = PhaseA
14609 #
14610  if FSweepMode.get() > 0 and BodeScreenStatus.get() > 0:
14611  FSweepAdB.append(numpy.amax(FFTresultA))
14612  FSweepBdB.append(numpy.amax(FFTresultB))
14613  FSweepAPh.append(PhaseA[numpy.argmax(FFTresultA)])
14614  FSweepBPh.append(PhaseB[numpy.argmax(FFTresultB)])
14615 
14616  TRACEresetFreq = False # Trace reset done
14617 
14618 def MakeFreqTrace(): # Update the grid and trace
14619  global FFTmemoryA, FFTresultA
14620  global FFTmemoryB, FFTresultB
14621  global FFTresultAWGA, FFTresultAWGB, ShowAWGASA, ShowAWGBSA
14622  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
14623  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep
14624  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
14625  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14626  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakIndexA, PeakIndexB
14627  global PeakfreqA, PeakfreqB, Two_X_Sample
14628  global DBdivindex # Index value
14629  global DBdivlist # dB per division list
14630  global DBlevel # Reference level
14631  global GRHF,GRWF # Screenheight, Screenwidth
14632  global AWGSAMPLErate, HScale, Fsample, SAMPLErate, BaseSampleRate
14633  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
14634  global STARTsample, STOPsample, LoopNum, FSweepMode, FreqTraceMode, SMPfft
14635  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
14636  global T1Fline, T2Fline, TFMline, T1Pline, T2Pline, TAFline, TBFline
14637  global Vdiv # Number of vertical divisions
14638  global X0LF, Y0TF # Left top X value, Left top Y value
14639 
14640  # Set the TRACEsize variable
14641  TRACEsize = 0
14642  try:
14643  StartFrequency = float(StartFreqEntry.get())
14644  except:
14645  StartFreqEntry.delete(0,"end")
14646  StartFreqEntry.insert(0,100)
14647  StartFrequency = 100
14648  try:
14649  StopFrequency = float(StopFreqEntry.get())
14650  except:
14651  StopFreqEntry.delete(0,"end")
14652  StopFreqEntry.insert(0,50000)
14653  StopFrequency = 50000
14654  if StartFrequency > StopFrequency :
14655  StopFreqEntry.delete(0,"end")
14656  StopFreqEntry.insert(0,50000)
14657  StopFrequency = 50000
14658  if StopFrequency < StartFrequency :
14659  StopFreqEntry.delete(0,"end")
14660  StopFreqEntry.insert(0,50000)
14661  StopFrequency = 50000
14662  try:
14663  Phasecenter = int(PhCenFreqEntry.get())
14664  RelPhaseCenter.set(Phasecenter)
14665  except:
14666  PhCenFreqEntry.delete(0,"end")
14667  PhCenFreqEntry.insert(0,0)
14668  RelPhaseCenter.set(0)
14669  Phasecenter = 0
14670  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
14671  if SAvertmaxEntry.get() == "10.0":
14672  SAvertmax = 10.0
14673  elif SAvertmaxEntry.get() == "1.0":
14674  SAvertmax = 1.0
14675  elif SAvertmaxEntry.get() == "0.1":
14676  SAvertmax = 0.1
14677  elif SAvertmaxEntry.get() == "10mV":
14678  SAvertmax = 1.0E-2
14679  elif SAvertmaxEntry.get() == "1mV":
14680  SAvertmax = 1.0E-3
14681  elif SAvertmaxEntry.get() == "100uV":
14682  SAvertmax = 1.0E-4
14683  elif SAvertmaxEntry.get() == "10uV":
14684  SAvertmax = 1.0E-5
14685  elif SAvertmaxEntry.get() == "1uV":
14686  SAvertmax = 1.0E-6
14687  elif SAvertmaxEntry.get() == "100nV":
14688  SAvertmax = 1.0E-7
14689  elif SAvertmaxEntry.get() == "10nV":
14690  SAvertmax = 1.0E-8
14691  else:
14692  SAvertmax = float(SAvertmaxEntry.get())
14693  if SAvertmax < 0.0: # negative values not allowed
14694  SAvertmaxEntry.delete(0,"end")
14695  SAvertmaxEntry.insert(0, "1mV")
14696  SAvertmax = 1.0E-3
14697  except:
14698  SAvertmaxEntry.delete(0,"end")
14699  SAvertmaxEntry.insert(0, "1mV")
14700  SAvertmax = 1.0E-3
14701  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
14702  if SAvertminEntry.get() == "10.0":
14703  SAvertmin = 10.0
14704  elif SAvertminEntry.get() == "1.0":
14705  SAvertmin = 1.0
14706  elif SAvertminEntry.get() == "0.1":
14707  SAvertmin = 0.1
14708  elif SAvertminEntry.get() == "10mV":
14709  SAvertmin = 1.0E-2
14710  elif SAvertminEntry.get() == "1mV":
14711  SAvertmin = 1.0E-3
14712  elif SAvertminEntry.get() == "100uV":
14713  SAvertmin = 1.0E-4
14714  elif SAvertminEntry.get() == "10uV":
14715  SAvertmin = 1.0E-5
14716  elif SAvertminEntry.get() == "1uV":
14717  SAvertmin = 1.0E-6
14718  elif SAvertminEntry.get() == "100nV":
14719  SAvertmin = 1.0E-7
14720  elif SAvertminEntry.get() == "10nV":
14721  SAvertmin = 1.0E-8
14722  else:
14723  SAvertmin = float(SAvertminEntry.get())
14724  if SAvertmin < 0.0: # negative values not allowed
14725  SAvertminEntry.delete(0,"end")
14726  SAvertminEntry.insert(0, "1uV")
14727  SAvertmin = 1.0E-6
14728  except:
14729  SAvertminEntry.delete(0,"end")
14730  SAvertminEntry.insert(0, "1uV")
14731  SAvertmin = 1.0E-6
14732  if ShowC1_VdB.get() == 1 or ShowMathSA.get() > 0:
14733  TRACEsize = len(FFTresultA) # Set the trace length
14734  elif ShowC2_VdB.get() == 1 or ShowMathSA.get() > 0:
14735  TRACEsize = len(FFTresultB)
14736  elif ShowAWGASA.get() > 0:
14737  TRACEsize = len(FFTresultAWGA)
14738  elif ShowAWGBSA.get() > 0:
14739  TRACEsize = len(FFTresultAWGB)
14740  #print(TRACEsize)
14741  if TRACEsize == 0: # If no trace, skip rest of this routine
14742  return()
14743  if FSweepMode.get() > 0 and LoopNum.get() == NSteps.get():
14744  PhaseA = PhaseMemoryA
14745  PhaseB = PhaseMemoryB
14746  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
14747  # Vertical conversion factors (level dBs) and border limits
14748  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14749  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
14750  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
14751  YVc = float(Y0TF) + YVconv * SAvertmax
14752  Ymin = Y0TF # Minimum position of screen grid (top)
14753  Ymax = Y0TF + GRHF # Maximum position of screen grid (bottom)
14754  Yphconv = float(GRHF) / 360
14755  Yp = float(Y0TF) + Yphconv + 180
14756  # Horizontal conversion factors (frequency Hz) and border limits
14757  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
14758  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
14759  LogFStop = math.log10(StopFrequency)
14760  try:
14761  LogFStart = math.log10(StartFrequency)
14762  except:
14763  LogFStart = 0.0
14764  LogFpixel = (LogFStop - LogFStart) / GRWF
14765  #
14766  try:
14767  LogVStop = math.log10(SAvertmax)
14768  except:
14769  LogVStop = 0.0
14770  try:
14771  LogVStart = math.log10(SAvertmin)
14772  except:
14773  LogVStart = -10
14774  LogVpixel = (LogVStop - LogVStart) / GRHF
14775  #
14776  STARTsample = StartFrequency / Fsample # First sample in FFTresult[] that is used
14777  STARTsample = int(math.ceil(STARTsample)) # First within screen range
14778 
14779  STOPsample = StopFrequency / Fsample # Last sample in FFTresult[] that is used
14780  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
14781 
14782  MAXsample = TRACEsize # Just an out of range check
14783  if STARTsample > (MAXsample - 1):
14784  STARTsample = MAXsample - 1
14785 
14786  if STOPsample > MAXsample:
14787  STOPsample = MAXsample
14788 
14789  T1Fline = []
14790  T2Fline = []
14791  TAFline = []
14792  TBFline = []
14793  T1Pline = []
14794  T2Pline = []
14795  TFMline = []
14796  n = STARTsample
14797  PeakIndexA = PeakIndexB = n
14798  PeakdbA = PeakdbB = PeakMdb = -200 # PeakdbB
14799  while n <= STOPsample:
14800  F = n * Fsample
14801  if HScale.get() == 1:
14802  try:
14803  LogF = math.log10(F) # convet to log Freq
14804  x = X0LF + (LogF - LogFStart)/LogFpixel
14805  except:
14806  x = X0LF
14807  else:
14808  x = X0LF + (F - StartFrequency) / Fpixel
14809  if ShowC1_VdB.get() == 1:
14810  T1Fline.append(int(x + 0.5))
14811  try:
14812  if SAVScale.get() == 0:
14813  if SAVPSD.get() == 1:
14814  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth))
14815  else:
14816  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14817  ya = Yc - Yconv * dbA
14818  else:
14819  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14820  V = 10.0**(dbA/20.0)# convert back to RMS Volts
14821  if SAVPSD.get() == 1:
14822  V = V/math.sqrt(FBinWidth) # per root Hz
14823  if SAVScale.get() == 2:
14824  try:
14825  LogV = math.log10(V) # convet to log Volts
14826  ya = YVc - (LogV - LogVStart)/LogVpixel
14827  except:
14828  ya = YVc - YVconv * V
14829  else:
14830  ya = YVc - YVconv * V
14831  except:
14832  ya = Ymax
14833  if (ya < Ymin):
14834  ya = Ymin
14835  if (ya > Ymax):
14836  ya = Ymax
14837  if dbA > PeakdbA:
14838  PeakdbA = dbA
14839  PeakyA = int(ya + 0.5)
14840  PeakxA = int(x + 0.5)
14841  PeakfreqA = F
14842  PeakIndexA = n
14843  T1Fline.append(int(ya + 0.5))
14844  if ShowC2_VdB.get() == 1:
14845  T2Fline.append(int(x + 0.5))
14846  try:
14847  if SAVScale.get() == 0:
14848  if SAVPSD.get() == 1:
14849  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
14850  else:
14851  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
14852  yb = Yc - Yconv * dbB
14853  else:
14854  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
14855  V = 10.0**(dbB/20.0)# RMS Volts
14856  if SAVPSD.get() == 1:
14857  V = V/math.sqrt(FBinWidth) # per root Hz
14858  if SAVScale.get() == 2:
14859  try:
14860  LogV = math.log10(V) # convet to log Volts
14861  yb = YVc - (LogV - LogVStart)/LogVpixel
14862  except:
14863  yb = YVc - YVconv * V
14864  else:
14865  yb = YVc - YVconv * V
14866  except:
14867  yb = Ymax
14868  if (yb < Ymin):
14869  yb = Ymin
14870  if (yb > Ymax):
14871  yb = Ymax
14872  if dbB > PeakdbB:
14873  PeakdbB = dbB
14874  PeakyB = int(yb + 0.5)
14875  PeakxB = int(x + 0.5)
14876  PeakfreqB = F
14877  PeakIndexB = n
14878  T2Fline.append(int(yb + 0.5))
14879  if ShowAWGASA.get() > 0:
14880  TAFline.append(int(x + 0.5))
14881  try:
14882  if SAVPSD.get() == 1:
14883  dbA = 10 * math.log10(float(FFTresultAWGA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14884  else:
14885  dbA = 10 * math.log10(float(FFTresultAWGA[n])) # Convert power to DBs
14886  ya = Yc - Yconv * dbA
14887  except:
14888  ya = Ymax
14889  if (ya < Ymin):
14890  ya = Ymin
14891  if (ya > Ymax):
14892  ya = Ymax
14893  TAFline.append(int(ya + 0.5))
14894  if ShowAWGBSA.get() > 0:
14895  TBFline.append(int(x + 0.5))
14896  try:
14897  if SAVPSD.get() == 1:
14898  dbA = 10 * math.log10(float(FFTresultAWGB[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14899  else:
14900  dbA = 10 * math.log10(float(FFTresultAWGb[n])) # Convert power to DBs
14901  ya = Yc - Yconv * dbA
14902  except:
14903  ya = Ymax
14904  if (ya < Ymin):
14905  ya = Ymin
14906  if (ya > Ymax):
14907  ya = Ymax
14908  TBFline.append(int(ya + 0.5))
14909  if ShowC1_P.get() == 1:
14910  T1Pline.append(int(x + 0.5))
14911  if FSweepMode.get() > 0:
14912  RelPhase = PhaseMemoryA[n]-PhaseMemoryB[n]
14913  else:
14914  RelPhase = PhaseA[n]-PhaseB[n]
14915  RelPhase = RelPhase - Phasecenter
14916  if RelPhase > 180:
14917  RelPhase = RelPhase - 360
14918  elif RelPhase < -180:
14919  RelPhase = RelPhase + 360
14920  if Two_X_Sample.get() == 0:
14921  PhErr = 0.0018 * n * Fsample # calculate phase error due half sample period offset
14922  RelPhase = RelPhase + PhErr - 12.0
14923  else:
14924  RelPhase = RelPhase - 9.0
14925  ya = Yp - Yphconv * RelPhase
14926  T1Pline.append(int(ya + 0.5))
14927  if ShowC2_P.get() == 1:
14928  T2Pline.append(int(x + 0.5))
14929  if FSweepMode.get() > 0:
14930  RelPhase = PhaseMemoryB[n]-PhaseMemoryA[n]
14931  else:
14932  RelPhase = PhaseB[n]-PhaseA[n]
14933  RelPhase = RelPhase - Phasecenter
14934  if RelPhase > 180:
14935  RelPhase = RelPhase - 360
14936  elif RelPhase < -180:
14937  RelPhase = RelPhase + 360
14938  if Two_X_Sample.get() == 0:
14939  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
14940  RelPhase = RelPhase - PhErr - 12.0
14941  else:
14942  RelPhase = RelPhase - 9.0
14943  ya = Yp - Yphconv * RelPhase
14944  T2Pline.append(int(ya + 0.5))
14945  if ShowMathSA.get() > 0:
14946  TFMline.append(int(x + 0.5))
14947  if SAVPSD.get() == 1:
14948  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14949  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
14950  else:
14951  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14952  dbB = 10 * math.log10(float(FFTresultB[n]))
14953  if ShowMathSA.get() == 1:
14954  MdB = dbA - dbB
14955  elif ShowMathSA.get() == 2:
14956  MdB = dbB - dbA
14957  yb = Yc - Yconv * MdB
14958  if (yb < Ymin):
14959  yb = Ymin
14960  if (yb > Ymax):
14961  yb = Ymax
14962  if MdB > PeakMdb:
14963  PeakMdb = MdB
14964  PeakyM = int(yb + 0.5)
14965  PeakxM = int(x + 0.5)
14966  PeakfreqM = F
14967  TFMline.append(int(yb + 0.5))
14968  n = n + 1
14969 #
14970 # make Bode Plot Traces
14971 def MakeBodeTrace(): # Update the grid and trace
14972  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins
14973  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
14974  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14975  global PeakxM, PeakyM, PeakMdb, PeakfreqM
14976  global PeakfreqA, PeakfreqB, Two_X_Sample, PhaseOffset1x, PhaseOffset2x
14977  global DBdivindexBP # Index value
14978  global DBdivlist # dB per division list
14979  global DBlevelBP # Reference level
14980  global GRHBP # Screenheight
14981  global GRWBP # Screenwidth
14982  global AWGSAMPLErate, HScaleBP, RUNstatus, SAMPLErate, BaseSampleRate
14983  global StartBodeEntry, StopBodeEntry, SMPfft
14984  global STARTsample, STOPsample, LoopNum, FSweepMode
14985  global FreqTraceMode, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
14986  global TAFline, TBFline, TBPMline, TAPline, TBPline
14987  global Vdiv # Number of vertical divisions
14988  global X0LBP # Left top X value
14989  global Y0TBP # Left top Y value
14990  global ResScale, NetworkScreenStatus, Show_Rseries, NSweepSeriesR, Show_Xseries, NSweepSeriesX
14991  global Show_Magnitude, NSweepSeriesMag, Show_Angle, NSweepSeriesAng
14992  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
14993 
14994  # Set the TRACEsize variable
14995  TRACEsize = 0
14996  if ShowCA_VdB.get() == 1 or ShowMathBP.get() > 0:
14997  TRACEsize = len(FStep) # Set the trace length
14998  elif ShowCB_VdB.get() == 1 or ShowMathBP.get() > 0:
14999  TRACEsize = len(FStep)
15000  if TRACEsize == 0: # If no trace, skip rest of this routine
15001  return()
15002  #
15003  try:
15004  EndFreq = float(StopBodeEntry.get())
15005  except:
15006  StopBodeEntry.delete(0,"end")
15007  StopBodeEntry.insert(0,10000)
15008  EndFreq = 10000
15009  try:
15010  BeginFreq = float(StartBodeEntry.get())
15011  except:
15012  StartBodeEntry.delete(0,"end")
15013  StartBodeEntry.insert(0,100)
15014  BeginFreq = 100
15015  try:
15016  Phasecenter = float(PhCenBodeEntry.get())
15017  RelPhaseCenter.set(Phasecenter)
15018  except:
15019  PhCenBodeEntry.delete(0,"end")
15020  PhCenBodeEntry.insert(0,0)
15021  RelPhaseCenter.set(0)
15022  Phasecenter = 0
15023  try:
15024  Impedcenter = float(ImCenBodeEntry.get())
15025  ImpedanceCenter.set(Impedcenter)
15026  except:
15027  ImCenBodeEntry.delete(0,"end")
15028  ImCenBodeEntry.insert(0,0)
15029  ImpedanceCenter.set(0)
15030  Impedcenter = 0
15031  #
15032  HalfSAMPLErate = SAMPLErate/2
15033  BeginIndex = int((BeginFreq/HalfSAMPLErate)*16384)
15034  EndIndex = int((EndFreq/HalfSAMPLErate)*16384)
15035  CurrentFreqX = X0LBP + 14
15036  if FSweepMode.get() > 0 and len(FSweepAdB) > 4:
15037  # Vertical conversion factors (level dBs) and border limits
15038  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15039  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
15040  Ymin = Y0TBP # Minimum position of screen grid (top)
15041  Ymax = Y0TBP + GRHBP # Maximum position of screen grid (bottom)
15042  Yphconv = float(GRHBP) / 360 # degrees per pixel
15043  Yp = float(Y0TBP) + Yphconv + 180
15044  x1 = X0LBP + 14
15045  # Horizontal conversion factors (frequency Hz) and border limits
15046  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
15047  LogFStop = math.log10(EndFreq)
15048  try:
15049  LogFStart = math.log10(BeginFreq)
15050  except:
15051  LogFStart = 0.0
15052  LogFpixel = (LogFStop - LogFStart) / GRWBP
15053  TAFline = []
15054  TBFline = []
15055  TAPline = []
15056  TBPline = []
15057  TIARline = []
15058  TIAXline = []
15059  TIAMagline = []
15060  TIAAngline = []
15061  TBPMline = []
15062  PeakdbA = -200
15063  PeakdbB = -200
15064  PeakMdb = -200
15065  n = 0
15066  for n in range(len(FSweepAdB)): # while n < len(FStep):
15067  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
15068  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
15069  else:
15070  F = FBins[int(FStep[0])]
15071  if F >= BeginFreq and F <= EndFreq:
15072  if HScaleBP.get() == 1:
15073  try:
15074  LogF = math.log10(F) # convet to log Freq
15075  x = x1 + (LogF - LogFStart)/LogFpixel
15076  except:
15077  x = x1
15078  else:
15079  x = x1 + (F - BeginFreq) / Fpixel
15080  CurrentFreqX = x
15081  if ShowCA_VdB.get() == 1:
15082  TAFline.append(int(x + 0.5))
15083  try:
15084  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
15085  ya = Yc - Yconv * dbA
15086  except:
15087  ya = Ymax
15088  if (ya < Ymin):
15089  ya = Ymin
15090  if (ya > Ymax):
15091  ya = Ymax
15092  if dbA > PeakdbA:
15093  PeakdbA = dbA
15094  PeakyA = int(ya + 0.5)
15095  PeakxA = int(x + 0.5)
15096  PeakfreqA = F
15097  TAFline.append(int(ya + 0.5))
15098  if ShowCB_VdB.get() == 1:
15099  TBFline.append(int(x + 0.5))
15100  try:
15101  dbB = 10 * math.log10(float(FSweepBdB[n]))
15102  yb = Yc - Yconv * dbB
15103  except:
15104  yb = Ymax
15105  if (yb < Ymin):
15106  yb = Ymin
15107  if (yb > Ymax):
15108  yb = Ymax
15109  if dbB > PeakdbB:
15110  PeakdbB = dbB
15111  PeakyB = int(yb + 0.5)
15112  PeakxB = int(x + 0.5)
15113  PeakfreqB = F
15114  TBFline.append(int(yb + 0.5))
15115  if ShowCA_P.get() == 1:
15116  TAPline.append(int(x + 0.5))
15117  RelPhase = FSweepAPh[n] - FSweepBPh[n]
15118  RelPhase = RelPhase - Phasecenter
15119  if RelPhase > 180:
15120  RelPhase = RelPhase - 360
15121  elif RelPhase < -180:
15122  RelPhase = RelPhase + 360
15123  if Two_X_Sample.get() == 0:
15124  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15125  RelPhase = RelPhase + PhErr - PhaseOffset1x
15126  else:
15127  RelPhase = RelPhase - PhaseOffset2x
15128  ya = Yp - Yphconv * RelPhase
15129  TAPline.append(int(ya + 0.5))
15130  if ShowCB_P.get() == 1:
15131  TBPline.append(int(x + 0.5))
15132  RelPhase = FSweepBPh[n] - FSweepAPh[n]
15133  RelPhase = RelPhase - Phasecenter
15134  if RelPhase > 180:
15135  RelPhase = RelPhase - 360
15136  elif RelPhase < -180:
15137  RelPhase = RelPhase + 360
15138  if Two_X_Sample.get() == 0:
15139  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15140  RelPhase = RelPhase - PhErr - PhaseOffset1x
15141  else:
15142  RelPhase = RelPhase - PhaseOffset2x
15143  ya = Yp - Yphconv * RelPhase
15144  TBPline.append(int(ya + 0.5))
15145  if ShowMathBP.get() > 0:
15146  TBPMline.append(int(x + 0.5))
15147  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
15148  dbB = 10 * math.log10(float(FSweepBdB[n]))
15149  if ShowMathBP.get() == 1:
15150  MdB = dbA - dbB
15151  elif ShowMathBP.get() == 2:
15152  MdB = dbB - dbA
15153  yb = Yc - Yconv * MdB
15154  if (yb < Ymin):
15155  yb = Ymin
15156  if (yb > Ymax):
15157  yb = Ymax
15158  if MdB > PeakMdb:
15159  PeakMdb = MdB
15160  PeakyM = int(yb + 0.5)
15161  PeakxM = int(x + 0.5)
15162  PeakfreqM = F
15163  TBPMline.append(int(yb + 0.5))
15164 # draw impedance trace if necessary
15165  if NetworkScreenStatus.get() > 0:
15166  ycenter = Y0TBP + (GRHBP/2)
15167  OhmsperPixel = float(ResScale.get())*Vdiv.get()/GRHBP
15168  n = 0
15169  for n in range(len(NSweepSeriesR)): # while n < len(FStep):
15170  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
15171  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
15172  else:
15173  F = FBins[int(FStep[0])]
15174  if F >= BeginFreq and F <= EndFreq:
15175  if HScaleBP.get() == 1:
15176  try:
15177  LogF = math.log10(F) # convet to log Freq
15178  x = x1 + (LogF - LogFStart)/LogFpixel
15179  except:
15180  x = x1
15181  else:
15182  x = x1 + (F - BeginFreq) / Fpixel
15183  if Show_Rseries.get() == 1:
15184  TIARline.append(int(x + 0.5))
15185  y1 = ycenter - ((NSweepSeriesR[n]-Impedcenter) / OhmsperPixel)
15186  if (y1 < Ymin):
15187  y1 = Ymin
15188  if (y1 > Ymax):
15189  y1 = Ymax
15190  TIARline.append(y1)
15191  if Show_Xseries.get() == 1:
15192  TIAXline.append(int(x + 0.5))
15193  y1 = ycenter - ((NSweepSeriesX[n]-Impedcenter) / OhmsperPixel)
15194  if (y1 < Ymin):
15195  y1 = Ymin
15196  if (y1 > Ymax):
15197  y1 = Ymax
15198  TIAXline.append(y1)
15199  if Show_Magnitude.get() == 1:
15200  TIAMagline.append(int(x + 0.5))
15201  y1 = ycenter - ((NSweepSeriesMag[n]-Impedcenter) / OhmsperPixel)
15202  if (y1 < Ymin):
15203  y1 = Ymin
15204  if (y1 > Ymax):
15205  y1 = Ymax
15206  TIAMagline.append(y1)
15207  if Show_Angle.get() == 1:
15208  TIAAngline.append(int(x + 0.5))
15209  y1 = ycenter - Yphconv * (NSweepSeriesAng[n]-Phasecenter)
15210  if (y1 < Ymin):
15211  y1 = Ymin
15212  if (y1 > Ymax):
15213  y1 = Ymax
15214  TIAAngline.append(y1)
15215 #
15216 def MakeBodeScreen(): # Update the screen with traces and text
15217  global CANVASheightBP, CANVASwidthBP, SmoothCurvesBP
15218  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
15219  global PeakxM, PeakyM, PeakMdb, PeakfreqM
15220  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
15221  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
15222  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
15223  global COLORgrid # The colors
15224  global COLORsignalband, COLORtext
15225  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
15226  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
15227  global DBdivindexBP # Index value
15228  global DBdivlist # dB per division list
15229  global DBlevelBP # Reference level
15230  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
15231  global X0LBP # Left top X value
15232  global Y0TBP # Left top Y value
15233  global GRWBP # Screenwidth
15234  global GRHBP # Screenheight
15235  global FontSize
15236  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
15237  global AWGSAMPLErate, HScaleBP, SAMPLErate, BaseSampleRate
15238  global SMPfft # number of FFT samples
15239  global StartBodeEntry, StopBodeEntry
15240  global ShowCA_P, ShowCB_P, ShowRA_VdB, ShowRB_VdB, ShowMarkerBP
15241  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP
15242  global ShowMathBP, BodeDisp, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
15243  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
15244  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, NetworkScreenStatus
15245  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
15246  global TAFline, TBFline, TAPline, TAFRline, TBFRline, TBPMline, TBPRMline
15247  global TAPRline, TBPRline
15248  global TRACEaverage # Number of traces for averageing
15249  global FreqTraceMode # 1 normal 2 max 3 average
15250  global Vdiv, ResScale # Number of vertical divisions
15251  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
15252  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
15253 
15254  # Delete all items on the screen
15255  MarkerFreqNum = 0
15256  Bodeca.delete(ALL) # remove all items
15257 
15258  try:
15259  EndFreq = float(StopBodeEntry.get())
15260  except:
15261  StopBodeEntry.delete(0,"end")
15262  StopBodeEntry.insert(0,10000)
15263  EndFreq = 10000
15264  try:
15265  BeginFreq = float(StartBodeEntry.get())
15266  except:
15267  StartBodeEntry.delete(0,"end")
15268  StartBodeEntry.insert(0,100)
15269  BeginFreq = 100
15270  try:
15271  Phasecenter = float(PhCenBodeEntry.get())
15272  RelPhaseCenter.set(Phasecenter)
15273  except:
15274  PhCenBodeEntry.delete(0,"end")
15275  PhCenBodeEntry.insert(0,0)
15276  RelPhaseCenter.set(0)
15277  Phasecenter = 0
15278  try:
15279  Impedcenter = float(ImCenBodeEntry.get())
15280  ImpedanceCenter.set(Impedcenter)
15281  except:
15282  ImCenBodeEntry.delete(0,"end")
15283  ImCenBodeEntry.insert(0,0)
15284  ImpedanceCenter.set(0)
15285  Impedcenter = 0
15286  #
15287  # Draw horizontal grid lines
15288  i = 0
15289  x1 = X0LBP + 14
15290  x2 = x1 + GRWBP
15291  while (i <= Vdiv.get()):
15292  y = Y0TBP + i * GRHBP/Vdiv.get()
15293  Dline = [x1,y,x2,y]
15294  if i == 0 or i == Vdiv.get():
15295  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15296  else:
15297  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15298  Vaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
15299  Vaxis_label = str(Vaxis_value)
15300  Bodeca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
15301  if ShowCA_P.get() == 1 or ShowCB_P.get() == 1 or Show_Angle.get() == 1:
15302  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get()))) + Phasecenter
15303  Vaxis_label = str(Vaxis_value)
15304  Bodeca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
15305  if NetworkScreenStatus.get() > 0:
15306  if Show_Rseries.get() == 1 or Show_Xseries.get() == 1 or Show_Magnitude.get() == 1:
15307  RperDiv = float(ResScale.get())
15308  Vaxis_value = ( (RperDiv * Vdiv.get()/2) - (i * RperDiv) ) + Impedcenter
15309  if Vaxis_value > 500 or Vaxis_value < -500:
15310  Vaxis_value = Vaxis_value/1000.0
15311  if Vaxis_value > 5 or Vaxis_value < -5:
15312  Vaxis_label = ' {0:.0f}'.format(Vaxis_value) + 'K'
15313  else:
15314  Vaxis_label = ' {0:.1f}'.format(Vaxis_value) + 'K'
15315  elif Vaxis_value > 50 or Vaxis_value < -50:
15316  Vaxis_label = ' {0:.1f} '.format(Vaxis_value)
15317  elif Vaxis_value > 5 or Vaxis_value < -55:
15318  Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
15319  else:
15320  Vaxis_label = ' {0:.3f} '.format(Vaxis_value)
15321  Bodeca.create_text(x1-23, y, text=Vaxis_label, fill=COLORtrace5, anchor="e", font=("arial", FontSize ))
15322  i = i + 1
15323  # Draw vertical grid lines
15324  i = 0
15325  y1 = Y0TBP
15326  y2 = Y0TBP + GRHBP
15327  if HScaleBP.get() == 1:
15328  F = 1.0
15329  LogFStop = math.log10(EndFreq)
15330  try:
15331  LogFStart = math.log10(BeginFreq)
15332  except:
15333  LogFStart = 0.0
15334  LogFpixel = (LogFStop - LogFStart) / GRWBP
15335  # draw left and right edges
15336  while F <= EndFreq:
15337  if F >= BeginFreq:
15338  try:
15339  LogF = math.log10(F) # convet to log Freq
15340  x = x1 + (LogF - LogFStart)/LogFpixel
15341  except:
15342  x = x1
15343  Dline = [x,y1,x,y2]
15344  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
15345  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15346  axis_label = str(F)
15347  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
15348  else:
15349  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15350 
15351  if F < 10:
15352  F = F + 1
15353  elif F < 100:
15354  F = F + 10
15355  elif F < 1000:
15356  F = F + 100
15357  elif F < 1000:
15358  F = F + 100
15359  elif F < 10000:
15360  F = F + 1000
15361  elif F < 100000:
15362  F = F + 10000
15363  elif F < 200000:
15364  F = F + 10000
15365  else:
15366  Freqdiv = (EndFreq - BeginFreq) / 10
15367  while (i < 11):
15368  x = x1 + i * GRWBP/10
15369  Dline = [x,y1,x,y2]
15370  if i == 0 or i == 10:
15371  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15372  else:
15373  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15374  axis_value = BeginFreq + (i * Freqdiv)
15375  axis_label = str(axis_value)
15376  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
15377  i = i + 1
15378  # Draw X - Y cursors if needed
15379  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
15380  LogFStop = math.log10(EndFreq)
15381  try:
15382  LogFStart = math.log10(BeginFreq)
15383  except:
15384  LogFStart = 0.0
15385  LogFpixel = (LogFStop - LogFStart) / GRWBP
15386  if ShowBPCur.get() > 0:
15387  Dline = [BPCursor, Y0TBP, BPCursor, Y0TBP+GRHBP]
15388  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
15389  # Horizontal conversion factors (frequency Hz) and border limits
15390  if HScaleBP.get() == 1:
15391  xfreq = 10**(((BPCursor-x1)*LogFpixel) + LogFStart)
15392  else:
15393  xfreq = ((BPCursor-x1)*Fpixel)+BeginFreq
15394  XFString = ' {0:.2f} '.format(xfreq)
15395  V_label = XFString + " Hz"
15396  Bodeca.create_text(BPCursor, Y0TBP+GRHBP+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
15397  #Bodeca.create_text(BPCursor+1, BdBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
15398 #
15399  if ShowBdBCur.get() > 0:
15400  Dline = [x1, BdBCursor, x1+GRWBP, BdBCursor]
15401  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
15402  if ShowBdBCur.get() == 1:
15403  # Vertical conversion factors (level dBs) and border limits
15404  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15405  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
15406  yvdB = ((Yc-BdBCursor)/Yconv)
15407  VdBString = ' {0:.1f} '.format(yvdB)
15408  V_label = VdBString + " dBV"
15409  else:
15410  # Vertical conversion factors (level degrees) and border limits
15411  Yconv = float(GRHBP) / 360.0 # Conversion factors, Yconv is the number of screenpoints per degree
15412  Yc = float(Y0TBP) # Yc is the 180 degree position
15413  yvdB = 180 + ((Yc-BdBCursor)/Yconv) + Phasecenter
15414  VdBString = ' {0:.1f} '.format(yvdB)
15415  V_label = VdBString + " Deg"
15416  Bodeca.create_text(x1+GRWBP+1, BdBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
15417  #Bodeca.create_text(BPCursor+1, BdBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
15418  #
15419  SmoothBool = SmoothCurvesBP.get()
15420  # Draw traces
15421  if len(TAFline) > 4: # Avoid writing lines with 1 coordinate
15422  # Write the trace CHA
15423  if OverRangeFlagA == 1:
15424  Bodeca.create_line(TAFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15425  else:
15426  Bodeca.create_line(TAFline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15427  if ShowMarkerBP.get() == 1:
15428  Peak_label = ' {0:.2f} '.format(PeakdbA) + ',' + ' {0:.1f} '.format(PeakfreqA)
15429  Bodeca.create_text(PeakxA, PeakyA, text=Peak_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
15430  if len(TBFline) > 4: # Avoid writing lines with 1 coordinate
15431  # Write the trace CHB
15432  if OverRangeFlagB == 1:
15433  Bodeca.create_line(TBFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15434  else:
15435  Bodeca.create_line(TBFline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15436  if ShowMarkerBP.get() == 1:
15437  Peak_label = ' {0:.2f} '.format(PeakdbB) + ',' + ' {0:.1f} '.format(PeakfreqB)
15438  Bodeca.create_text(PeakxB, PeakyB, text=Peak_label, fill=COLORtrace2, anchor="w", font=("arial", FontSize ))
15439  if len(TAPline) > 4: # Avoid writing lines with 1 coordinate
15440  # Write the phase trace A-B
15441  Bodeca.create_line(TAPline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15442  if len(TBPline) > 4: # Avoid writing lines with 1 coordinate
15443  # Write the phase trace A-B
15444  Bodeca.create_line(TBPline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15445  if ShowCA_RdB.get() == 1 and len(TAFRline) > 4: # Write the ref trace A if active
15446  Bodeca.create_line(TAFRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15447  if ShowMarkerBP.get() == 1:
15448  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
15449  Bodeca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="e", font=("arial", FontSize ))
15450  if ShowCB_RdB.get() == 1 and len(TBFRline) > 4: # Write the ref trace B if active
15451  Bodeca.create_line(TBFRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15452  if ShowMarkerBP.get() == 1:
15453  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
15454  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="w", font=("arial", FontSize ))
15455  if ShowCA_RP.get() == 1 and len(TAPRline) > 4: # Write the ref trace A if active
15456  Bodeca.create_line(TAPRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15457  if ShowCB_RP.get() == 1 and len(TBPRline) > 4: # Write the ref trace A if active
15458  Bodeca.create_line(TBPRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15459  if ShowMathBP.get() > 0 and len(TBPMline) > 4: # Write the Math trace if active
15460  Bodeca.create_line(TBPMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15461  if ShowMarkerBP.get() == 1:
15462  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
15463  Bodeca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="w", font=("arial", FontSize ))
15464  if ShowRMathBP.get() == 1 and len(TBPRMline) > 4: # Write the ref math trace if active
15465  Bodeca.create_line(TBPRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15466  if ShowMarkerBP.get() == 1:
15467  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
15468  Bodeca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="w", font=("arial", FontSize ))
15469  if Show_Rseries.get() == 1 and len(TIARline) > 4:
15470  Bodeca.create_line(TIARline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15471  if Show_Xseries.get() == 1 and len(TIAXline) > 4:
15472  Bodeca.create_line(TIAXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15473  if Show_Magnitude.get() == 1 and len(TIAMagline) > 4:
15474  Bodeca.create_line(TIAMagline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15475  if Show_Angle.get() == 1 and len(TIAAngline) > 4:
15476  Bodeca.create_line(TIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15477  if Show_RseriesRef.get() == 1 and len(RefIARline) > 4:
15478  Bodeca.create_line(RefIARline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15479  if Show_XseriesRef.get() == 1 and len(RefIAXline) > 4:
15480  Bodeca.create_line(RefIAXline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15481  if Show_MagnitudeRef.get() == 1 and len(RefIAMagline) > 4:
15482  Bodeca.create_line(RefIAMagline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15483  if Show_AngleRef.get() == 1 and len(RefIAAngline) > 4:
15484  Bodeca.create_line(RefIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15485 
15486  Dline = [CurrentFreqX, Y0TBP, CurrentFreqX, Y0TBP+GRHBP]
15487  Bodeca.create_line(Dline, dash=(2,2), fill=COLORgrid, width=GridWidth.get())
15488  if HScaleBP.get() == 1:
15489  xfreq = 10**(((CurrentFreqX-x1)*LogFpixel) + LogFStart)
15490  else:
15491  xfreq = ((CurrentFreqX-x1)*Fpixel)+BeginFreq
15492  XFString = ' {0:.0f} '.format(xfreq)
15493  V_label = XFString + " Hz"
15494  Bodeca.create_text(CurrentFreqX, Y0TBP+GRHBP+1, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
15495  # General information on top of the grid
15496 
15497  txt = " Sample rate: " + str(SAMPLErate)
15498  txt = txt + " FFT samples: " + str(SMPfft)
15499 
15500  txt = txt + " " + FFTwindowname
15501 
15502  x = X0LBP
15503  y = 12
15504  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
15505 
15506  # Start and stop frequency and dB/div and trace mode
15507  txt = str(BeginFreq) + " to " + str(EndFreq) + " Hz"
15508  txt = txt + " " + str(DBdivlist[DBdivindexBP.get()]) + " dB/div"
15509  txt = txt + " Level: " + str(DBlevelBP.get()) + " dB "
15510  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
15511 
15512  x = X0LBP
15513  y = Y0TBP+GRHBP+23
15514  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
15515 
15516  if FreqTraceMode.get() == 1:
15517  txt ="Normal mode "
15518 
15519  if FreqTraceMode.get() == 2:
15520  txt = "Peak hold mode "
15521 
15522  if FreqTraceMode.get() == 3:
15523  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
15524 
15525  if ZEROstuffing.get() > 0:
15526  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
15527  # Runstatus and level information
15528  if (RUNstatus.get() == 0):
15529  txt = txt + " Stopped "
15530  else:
15531  if BodeDisp.get() == 1:
15532  txt = txt + " Running "
15533  else:
15534  txt = txt + " Display off "
15535  if FSweepMode.get() > 0:
15536  txt = txt + " Freq Step = " + str(LoopNum.get())
15537  x = X0LBP
15538  y = Y0TBP+GRHBP+34
15539  IDtxt = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
15540 
15541 # Impedance analyzer routines -----
15542 def UpdateIAAll(): # Update Data, trace and screen
15543  global FFTBuffA, FFTBuffB
15544  global SMPfft
15545 
15546  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
15547  return
15548 
15549  MakeIATrace() # Update the traces
15550  UpdateIAScreen() # Update the screen
15551 
15552 def UpdateIATrace(): # Update trace and screen
15553  MakeIATrace() # Update traces
15554  UpdateIAScreen() # Update the screen
15555 
15556 def UpdateIAScreen(): # Update screen with trace and text
15557  MakeIAScreen() # Update the screen
15558  root.update() # Activate updated screens
15559 #
15560 def DoImpedance():
15561 
15562 # Input Variables
15563  global PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
15564  #(VZ/VA)from vector voltmeter
15565  # global VVangle # angle in degrees between VZ and VA
15566  global RsystemEntry # resistance of series resistor or power divider
15567 # Computed outputs
15568  # global VVangleCosine # cosine of vector voltmeter angle
15569  global ImpedanceMagnitude # in ohms
15570  global ImpedanceAngle # in degrees
15571  global ImpedanceRseries, ImpedanceXseries # in ohms
15572  global IA_Ext_Conf
15573 
15574  DEG2RAD = (math.pi / 180.0)
15575  SMALL = 1E-20
15576  try:
15577  ResValue = float(RsystemEntry.get())
15578  except:
15579  ResValue = 1000.0
15580 
15581  VA = math.pow(10,(PeakdbA/20))
15582  VB = math.pow(10,(PeakdbB/20))
15583  VVangleCosine = math.cos(math.radians(PeakRelPhase))
15584  if IA_Ext_Conf.get() == 1:
15585  VAB = math.pow(10,(PeakdbAB/20))
15586  VZ = VAB # VZ=VA-VB
15587  # VI = VB
15588  else:
15589  VZ = VB # VZ=VB
15590  VI = math.sqrt(VA**2 + VZ**2 - 2*VA*VZ*VVangleCosine)
15591  costheta = (VA**2 + VI**2 - VZ**2)/(2 * VA * VI)
15592  Za = ResValue * VA / VI
15593  ImpedanceRseries = Za * costheta - ResValue
15594  ImpedanceMagnitude = ResValue * VZ / VI
15595  # don't try to take square root of a negative number)
15596  ImpedanceXseries = math.sqrt(abs(ImpedanceMagnitude**2 - ImpedanceRseries**2))
15597 
15598  if(PeakRelPhase < 0.0):
15599  ImpedanceXseries = -ImpedanceXseries
15600  if IA_Ext_Conf.get() == 1:
15601  ImpedanceRseries = -ImpedanceRseries
15602  ImpedanceAngle = math.atan2(ImpedanceXseries, ImpedanceRseries) / DEG2RAD
15603 #
15604 def MakeIATrace(): # Update the grid and trace
15605  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
15606  global FFTmemoryB, FFTresultB
15607  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
15608  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
15609  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakphaseA, PeakphaseB
15610  global PeakfreqA, PeakfreqB, GainCorEntry, PhaseCorEntry, PhaseCorrection
15611  global DBdivindex # Index value
15612  global DBdivlist # dB per division list
15613  global DBlevel # Reference level
15614  global GRHIA # Screenheight
15615  global GRWIA # Screenwidth
15616  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SMPfft
15617  global STARTsample, STOPsample, LoopNum, FSweepMode
15618  global TRACEmode, Two_X_Sample, IA_Ext_Conf
15619  global T1Vline, T2Vline, TMline, T1Pline, T2Pline
15620  global Vdiv # Number of vertical divisions
15621  global X0LIA # Left top X value
15622  global Y0TIA # Left top Y value
15623  global ImpedanceMagnitude # in ohms
15624  global ImpedanceAngle # in degrees
15625  global ImpedanceRseries, ImpedanceXseries # in ohms
15626 
15627  # Set the TRACEsize variable
15628  TRACEsize = len(FFTresultA) # Set the trace length
15629 
15630  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
15631  # Horizontal conversion factors (frequency Hz) and border limits
15632  STARTsample = 0 # First sample in FFTresult[] that is used
15633  STARTsample = int(math.ceil(STARTsample)) # First within screen range
15634  if Two_X_Sample.get() == 0:
15635  STOPsample = (SAMPLErate * 0.45) / Fsample # Last sample in FFTresult[] that is used
15636  else:
15637  STOPsample = (SAMPLErate * 0.45) / Fsample
15638  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
15639 #
15640  RMScorr = 1.0 / SMPfft # For VOLTAGE!
15641  Powcorr = RMScorr **2 # vpktage squared For POWER!
15642  try:
15643  GainCorrection = float(eval(GainCorEntry.get()))
15644  except:
15645  GainCorEntry.delete(0,END)
15646  GainCorEntry.insert(0, GainCorrection)
15647 
15648  try:
15649  PhaseCorrection = float(eval(PhaseCorEntry.get()))
15650  except:
15651  PhaseCorEntry.delete(0,END)
15652  PhaseCorEntry.insert(0, PhaseCorrection)
15653 
15654  MAXsample = TRACEsize # Just an out of range check
15655  if STARTsample > (MAXsample - 1):
15656  STARTsample = MAXsample - 1
15657 
15658  if STOPsample > MAXsample:
15659  STOPsample = MAXsample - 1
15660 
15661  n = STARTsample
15662  PeakfreqA = PeakfreqB = PeakfreqM = F = n * Fsample
15663  PeakphaseA = PhaseA[n]
15664  PeakphaseB = PhaseB[n]
15665  #PeakphaseAB = PhaseAB[n]
15666  PeakSample = n
15667 
15668  PeakdbA = 10 * math.log10(float(FFTresultA[n]))
15669  PeakdbB = 10 * math.log10(float(FFTresultB[n]))
15670  PeakMdb = PeakdbA - PeakdbB
15671  if IA_Ext_Conf.get() == 1:
15672  PeakdbAB = 10 * math.log10(float(FFTresultAB[n]))
15673  while n <= STOPsample:
15674  F = n * Fsample
15675  try:
15676  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs, except for log(0) error
15677  except:
15678  dbA = -200
15679  if dbA > PeakdbA:
15680  PeakdbA = dbA
15681  PeakfreqA = F
15682  PeakphaseA = PhaseA[n]
15683  PeakSample = n
15684 
15685  try:
15686  dbB = 10 * math.log10(float(FFTresultB[n]))
15687  except:
15688  dbB = -200
15689  if dbB > PeakdbB:
15690  PeakdbB = dbB
15691  PeakfreqB = F
15692  PeakphaseB = PhaseB[n]
15693 
15694  if IA_Ext_Conf.get() == 1:
15695  try:
15696  dbAB = 10 * math.log10(float(FFTresultAB[n]))
15697  except:
15698  dbAB = -200
15699  if dbAB > PeakdbAB:
15700  PeakdbAB = dbAB
15701  PeakphaseAB = PhaseAB[n]
15702  RelPhase = PhaseA[n]-PhaseB[n]
15703  if RelPhase > 180:
15704  RelPhase = RelPhase - 360
15705  elif RelPhase < -180:
15706  RelPhase = RelPhase + 360
15707  if Two_X_Sample.get() == 0:
15708  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
15709  RelPhase = RelPhase + PhErr - 12.0
15710  else:
15711  RelPhase = RelPhase - 9.0
15712  n = n + 1
15713  if IA_Ext_Conf.get() == 1:
15714  PeakRelPhase = PeakphaseAB-PeakphaseA
15715  else:
15716  PeakRelPhase = PeakphaseB-PeakphaseA
15717 #
15718  if PeakRelPhase > 180:
15719  PeakRelPhase = PeakRelPhase - 360
15720  elif PeakRelPhase < -180:
15721  PeakRelPhase = PeakRelPhase + 360
15722  if Two_X_Sample.get() == 0:
15723  PhErr = 0.0018 * PeakSample * Fsample # calculate pahse error due half sample period offset
15724  PeakRelPhase = PeakRelPhase + PhaseCorrection - PhErr # - 12
15725  else:
15726  PeakRelPhase = PeakRelPhase + PhaseCorrection
15727  PeakdbB = PeakdbB + GainCorrection
15728  DoImpedance()
15729 
15731 def MakeIAScreen(): # Update the screen with traces and text
15732  global CANVASheightIA, CANVASwidthIA, IAca, TIAMline, TIAMRline
15733  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
15734  global PeakxM, PeakyM, PeakMdb, PeakfreqM, Two_X_Sample
15735  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
15736  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
15737  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
15738  global PeakphaseA, PeakphaseB, PeakRelPhase, PhaseCalEntry, CapZeroEntry
15739  global SmoothCurvesBP, TRACEwidth, GridWidth # The colors
15740  global COLORsignalband, COLORtext, COLORgrid, IASweepSaved
15741  global COLORtrace1, COLORtrace2, COLORtrace5, COLORtrace6
15742  global ResScale, DisplaySeries # Ohms per div
15743  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
15744  global X0LIA # Left top X value
15745  global Y0TIA # Left top Y value
15746  global GRWIA # Screenwidth
15747  global GRHIA # Screenheight
15748  global FontSize, IAGridType
15749  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
15750  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
15751  global SMPfft # number of FFT samples
15752  global TRACEaverage # Number of traces for averageing
15753  global FreqTraceMode # 1 normal 2 max 3 average
15754  global Vdiv # Number of vertical divisions
15755  global ImpedanceMagnitude # in ohms
15756  global ImpedanceAngle # in degrees
15757  global ImpedanceRseries, ImpedanceXseries, Cseries # in ohms / uF
15758  global LoopNum, NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
15759  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesC
15760 
15761  # Delete all items on the screen
15762  IAca.delete(ALL) # remove all items
15763  SmoothBool = SmoothCurvesBP.get()
15764  Cparallel = 0.0
15765  Rparallel = 0.0
15766  Lparallel = 0.0
15767  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
15768  xright = 10 + GRWIA/2 + ( Vdiv.get() * Radius ) # 5
15769  OhmsperPixel = float(ResScale.get())/Radius
15770  TRadius = Radius * Vdiv.get() # 5
15771  xcenter = GRWIA/2
15772  ycenter = GRHIA/2
15773  if IAGridType.get() == 0:
15774  # Draw circular grid lines
15775  i = 1
15776  xcenter = GRWIA/2
15777  ycenter = GRHIA/2
15778  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
15779  OhmsperPixel = float(ResScale.get())/Radius
15780  TRadius = Radius * Vdiv.get() # 5
15781  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
15782  while (i <= Vdiv.get()):
15783  x0 = xcenter - ( i * Radius )
15784  x1 = xcenter + ( i * Radius )
15785  y0 = ycenter - ( i * Radius )
15786  y1 = ycenter + ( i * Radius )
15787  axisvalue = float(ResScale.get()) * i
15788  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
15789  axisvalue = axisvalue / 1000
15790  ResTxt = '{0:.1f}'.format(axisvalue)
15791  axis_label = str(ResTxt) + "K"
15792  elif axisvalue >= 100.0 or axisvalue <= -100.0:
15793  ResTxt = '{0:.1f}'.format(axisvalue)
15794  axis_label = str(ResTxt)
15795  elif axisvalue >= 10.0 or axisvalue <= -10.0:
15796  ResTxt = '{0:.2f}'.format(axisvalue)
15797  axis_label = str(ResTxt)
15798  else:
15799  ResTxt = '{0:.3f}'.format(axisvalue)
15800  axis_label = str(ResTxt)
15801  IAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
15802  IAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
15803  IAca.create_text(xright, y0, text=axis_label, fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15804  #
15805  i = i + 1
15806  IAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
15807  IAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
15808  RAngle = math.radians(45)
15809  y = TRadius*math.sin(RAngle)
15810  x = TRadius*math.cos(RAngle)
15811  IAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15812  IAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15813  IAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
15814  IAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15815  IAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
15816  IAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
15817  else:
15818  # Draw horizontal grid lines
15819  i = 0 - Vdiv.get()
15820  j = 0
15821  x1 = X0LIA
15822  x2 = X0LIA + TRadius * 2
15823  xcenter = x1 + (TRadius)
15824  OhmsperPixel = float(ResScale.get())/Radius
15825  while (i <= Vdiv.get()):
15826  y = Y0TIA + j * (TRadius/Vdiv.get())
15827  Dline = [x1,y,x2,y]
15828  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
15829  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15830  else:
15831  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15832  axisvalue = float(ResScale.get()) * -i
15833  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
15834  axisvalue = axisvalue / 1000
15835  ResTxt = '{0:.1f}'.format(axisvalue)
15836  axis_label = str(ResTxt) + "K"
15837  else:
15838  ResTxt = '{0:.0f}'.format(axisvalue)
15839  axis_label = str(ResTxt)
15840  IAca.create_text(x1-3, y, text=axis_label, fill=COLORtrace6, anchor="e", font=("arial", FontSize ))
15841  i = i + 1
15842  j = j + 1
15843  # Draw vertical grid lines
15844  i = 0 - Vdiv.get()
15845  j = 0
15846  y1 = Y0TIA
15847  y2 = Y0TIA + TRadius * 2
15848  ycenter = y1 + (TRadius)
15849  # "\n".join(axis_label)
15850  while (i <= Vdiv.get()): #
15851  x = x1 + j * (TRadius/Vdiv.get())
15852  Dline = [x,y1,x,y2]
15853  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
15854  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15855  else:
15856  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15857  axisvalue = float(ResScale.get()) * i
15858  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
15859  axisvalue = axisvalue / 1000
15860  ResTxt = '{0:.1f}'.format(axisvalue)
15861  axis_label = str(ResTxt) + "K"
15862  else:
15863  ResTxt = '{0:.0f}'.format(axisvalue)
15864  axis_label = str(ResTxt)
15865  IAca.create_text(x, y2+3, text=axis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
15866  i = i + 1
15867  j = j + 1
15868 # Draw traces
15869  # Add saved line if there
15870  if IASweepSaved.get() > 0:
15871  if len(TIAMRline) > 4:
15872  IAca.create_line(TIAMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15873 #
15874  x1 = xcenter + ( ImpedanceRseries / OhmsperPixel )
15875  if x1 > 1500:
15876  x1 = xright
15877  elif x1 < -500:
15878  x1 = xcenter - xright
15879  IAca.create_line(xcenter, ycenter, x1, ycenter, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
15880  y1 = ycenter - ( ImpedanceXseries / OhmsperPixel )
15881  if y1 > 1500:
15882  y1 = xright
15883  elif y1 < -500:
15884  y1 = ycenter - xright
15885  xmag = x1
15886  ymag = y1
15887  IAca.create_line(xcenter, ycenter, xcenter, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())
15888  MagRadius = ImpedanceMagnitude / OhmsperPixel
15889  y1 = ycenter - MagRadius*math.sin(math.radians(ImpedanceAngle))
15890  if y1 > 1500:
15891  y1 = xright
15892  elif y1 < -500:
15893  y1 = ycenter - xright
15894  x1 = xcenter + MagRadius*math.cos(math.radians(ImpedanceAngle))
15895  if x1 > 1500:
15896  x1 = xright
15897  elif x1 < -500:
15898  x1 = xcenter - xright
15899  IAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
15900 #
15901  TIAMline = []
15902  if len(NSweepSeriesMag) > 2:
15903  index = 0
15904  while index < len(NSweepSeriesMag):
15905  MagRadius = NSweepSeriesMag[index] / OhmsperPixel
15906  y1 = ycenter - MagRadius*math.sin(math.radians(NSweepSeriesAng[index]))
15907  if y1 > 1500:
15908  y1 = xright
15909  elif y1 < -500:
15910  y1 = ycenter - xright
15911  x1 = xcenter + MagRadius*math.cos(math.radians(NSweepSeriesAng[index]))
15912  if x1 > 1500:
15913  x1 = xright
15914  elif x1 < -500:
15915  x1 = xcenter - xright
15916  TIAMline.append(x1)
15917  TIAMline.append(y1)
15918  index = index + 1
15919  IAca.create_line(TIAMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15920 # display warning if input out of range
15921  if OverRangeFlagA == 1:
15922  x = X0LIA+GRWIA+10
15923  y = Y0TIA+GRHIA-40
15924  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15925  IAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15926  if OverRangeFlagB == 1:
15927  x = X0LIA+GRWIA+10
15928  y = Y0TIA+GRHIA-10
15929  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15930  IAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15931  # General information on top of the grid
15932 
15933  txt = " Sample rate: " + str(SAMPLErate)
15934  txt = txt + " FFT samples: " + str(SMPfft)
15935 
15936  txt = txt + " " + FFTwindowname
15937  if NetworkScreenStatus.get() > 0:
15938  txt = txt + " Sweep ON"
15939  else:
15940  txt = txt + " Sweep OFF"
15941  x = X0LIA
15942  y = 12
15943  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
15944  #
15945  x = X0LIA + GRWIA + 4
15946  y = 24
15947  txt = "Gain " + ' {0:.2f} '.format(PeakdbB-PeakdbA) + " dB"
15948  TXT9 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15949  y = y + 24
15950  txt = "Phase " + ' {0:.2f} '.format(PeakRelPhase) + " Degrees"
15951  TXT10 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15952  y = y + 24
15953  txt = "Freq " + ' {0:.1f} '.format(PeakfreqA) + " Hertz"
15954  TXT11 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15955  y = y + 24
15956  txt = "Impedance Magnitude"
15957  TXT1 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15958  y = y + 24
15959  if ImpedanceMagnitude >= 1000.0 or ImpedanceMagnitude <= -1000.0:
15960  txt = '{0:.2f}'.format(ImpedanceMagnitude/1000.0)
15961  txt = str(txt) + "K"
15962  elif ImpedanceMagnitude >= 100.0 or ImpedanceMagnitude <= -100.0:
15963  txt = ' {0:.1f} '.format(ImpedanceMagnitude)
15964  elif ImpedanceMagnitude >= 10.0 or ImpedanceMagnitude <= -10.0:
15965  txt = ' {0:.2f} '.format(ImpedanceMagnitude)
15966  else:
15967  txt = ' {0:.3f} '.format(ImpedanceMagnitude)
15968  TXT2 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15969  y = y + 24
15970  txt = "Impedance Angle"
15971  TXT3 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15972  y = y + 24
15973  txt = ' {0:.1f} '.format(ImpedanceAngle)
15974  TXT4 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15975  y = y + 24
15976  txt = "Impedance R series"
15977  TXT5 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15978  y = y + 24
15979  if ImpedanceRseries >= 1000.0 or ImpedanceRseries <= -1000.0:
15980  txt = '{0:.2f}'.format(ImpedanceRseries/1000.0)
15981  txt = str(txt) + "K"
15982  elif ImpedanceRseries >= 100.0 or ImpedanceRseries <= -100.0:
15983  txt = ' {0:.1f} '.format(ImpedanceRseries)
15984  elif ImpedanceRseries >= 10.0 or ImpedanceRseries <= -10.0:
15985  txt = ' {0:.2f} '.format(ImpedanceRseries)
15986  else:
15987  txt = ' {0:.3f} '.format(ImpedanceRseries)
15988  TXT6 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15989  y = y + 24
15990  txt = "Impedance X series"
15991  TXT7 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15992  y = y + 24
15993  if ImpedanceXseries >= 1000.0 or ImpedanceXseries <= -1000.0:
15994  txt = '{0:.2f}'.format(ImpedanceXseries/1000.0)
15995  txt = str(txt) + "K"
15996  elif ImpedanceXseries >= 100.0 or ImpedanceXseries <= -100.0:
15997  txt = ' {0:.1f} '.format(ImpedanceXseries)
15998  elif ImpedanceXseries >= 10.0 or ImpedanceXseries <= -10.0:
15999  txt = ' {0:.2f} '.format(ImpedanceXseries)
16000  else:
16001  txt = ' {0:.3f} '.format(ImpedanceXseries)
16002  TXT8 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
16003 #
16004  Cseries = 0.0
16005  Cparallel = 0.0
16006  Lseries = 0.0
16007  Lparallel = 0.0
16008  Rparallel = 0.0
16009  if ImpedanceXseries < 0: # calculate series capacitance
16010  y = y + 24
16011  try:
16012  Cseries = -1 / ( 2 * math.pi * PeakfreqA * ImpedanceXseries ) # in farads
16013  except:
16014  Cseries = 0
16015  Qseries = 1/(2*math.pi*PeakfreqA*Cseries*ImpedanceRseries)
16016  Cparallel = Cseries * (Qseries**2 / (1+Qseries**2))
16017  Cparallel = Cparallel * 1E6 # convert to micro Farads
16018  Rparallel = ImpedanceRseries * (1+Qseries**2)
16019  Cseries = Cseries * 1E6 # convert to micro Farads
16020  if DisplaySeries.get() == 0:
16021  txt = "Series Capacitance"
16022  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16023  y = y + 20
16024  if Cseries < 1:
16025  Ctext = Cseries * 1E3
16026  if Ctext < 1:
16027  Ctext = Ctext * 1E3
16028  CtextDis = Ctext + float(CapZeroEntry.get())
16029  txt = ' {0:.1f} '.format(CtextDis) + "pF"
16030  else:
16031  txt = ' {0:.3f} '.format(Ctext) + "nF"
16032  else:
16033  txt = ' {0:.3f} '.format(Cseries) + "uF"
16034  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16035  else:
16036  txt = "Parallel"
16037  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16038  y = y + 20
16039  if Cparallel < 1:
16040  Ctext = Cparallel * 1E3
16041  if Ctext < 1:
16042  Ctext = Ctext * 1E3
16043  txt = "Capacitance " + ' {0:.1f} '.format(Ctext) + "pF"
16044  else:
16045  txt = "Capacitance " + ' {0:.3f} '.format(Ctext) + "nF"
16046  else:
16047  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "uF"
16048  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16049  y = y + 20
16050  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
16051  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16052  y = y + 20
16053  dissp = abs(ImpedanceRseries/ImpedanceXseries) * 100 # Dissipation factor is ratio of XR to XC in percent
16054  txt = 'D = {0:.2f} '.format(dissp) + " %"
16055  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16056 
16057  elif ImpedanceXseries > 0: # calculate series inductance
16058  y = y + 24
16059  try:
16060  Lseries = ImpedanceXseries / ( 2 * 3.14159 * PeakfreqA ) # in henry
16061  except:
16062  Lseries = 0
16063  Qseries = (2*math.pi*PeakfreqA*Lseries)/ImpedanceRseries
16064  if Qseries == 0.0: # Check if divide by zero
16065  Qseries = 0.00001
16066  Lparallel = Lseries * ((1+Qseries**2) / Qseries**2)
16067  Lparallel = Lparallel * 1E3 # convert to millihenry
16068  Rparallel = ImpedanceRseries * (1+Qseries**2)
16069  Lseries = Lseries * 1E3 # in millihenry
16070  if DisplaySeries.get() == 0:
16071  txt = "Series Inductance"
16072  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16073  y = y + 22
16074  if Lseries < 1:
16075  Ltext = Lseries * 1E3
16076  txt = ' {0:.2f} '.format(Ltext) + "uH"
16077  else:
16078  txt = ' {0:.2f} '.format(Lseries) + "mH"
16079  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16080  else:
16081  txt = "Parallel"
16082  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16083  y = y + 20
16084  if Lparallel < 1:
16085  Ltext = Lparallel * 1E3
16086  txt = "Inductance " + ' {0:.2f} '.format(Ltext) + "uH"
16087  else:
16088  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "mH"
16089  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16090  y = y + 20
16091  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
16092  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16093  y = y + 20
16094  qf = abs(ImpedanceXseries/ImpedanceRseries) * 100 # Quality Factor is ratio of XL to XR
16095  txt = 'Q = {0:.2f} '.format(qf)
16096  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16097  #
16098  if LoopNum.get() > 1:
16099  if NetworkScreenStatus.get() > 0:
16100  NSweepSeriesR.append(ImpedanceRseries)
16101  NSweepSeriesX.append(ImpedanceXseries)
16102  NSweepSeriesMag.append(ImpedanceMagnitude) # in ohms
16103  NSweepSeriesAng.append(ImpedanceAngle) # in degrees
16104  NSweepParallelR.append(Rparallel)
16105  NSweepParallelC.append(Cparallel) # in uF
16106  NSweepParallelL.append(Lparallel) # in mH
16107  NSweepSeriesC.append(Cseries) # in uF
16108  NSweepSeriesL.append(Lseries) # in mH
16109  # Start and stop frequency and trace mode
16110  Fmax = int(SAMPLErate * 0.45)
16111  txt = "0.0 to " + str(Fmax) + " Hz"
16112 
16113  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
16114 
16115  x = X0LIA
16116  y = Y0TIA+GRHIA-13
16117  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
16118  txt = " "
16119  if FreqTraceMode.get() == 1:
16120  txt ="Normal mode "
16121 
16122  if FreqTraceMode.get() == 2:
16123  txt = "Peak hold mode "
16124 
16125  if FreqTraceMode.get() == 3:
16126  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
16127 
16128  if ZEROstuffing.get() > 0:
16129  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
16130  # Runstatus and level information
16131  if (RUNstatus.get() == 0):
16132  txt = txt + " Stopped "
16133  else:
16134  txt = txt + " Running "
16135  y = Y0TIA+GRHIA
16136  IDtxt = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
16137 #
16138 def IACaresize(event):
16139  global IAca, GRWIA, XOLIA, GRHIA, Y0TIA, CANVASwidthIA, CANVASheightIA, FontSize
16140 
16141  CANVASwidthIA = event.width - 4
16142  CANVASheightIA = event.height - 4
16143  GRWIA = CANVASwidthIA - (2 * X0LIA) - int(21.25 * FontSize) # 170 new grid width
16144  GRHIA = CANVASheightIA - Y0TIA - int(2.25 * FontSize) # 10 new grid height
16145  UpdateIAAll()
16146 #
16147 # ================ Make IA Window ==========================
16148 def MakeIAWindow():
16149  global iawindow, IAca, logo, IAScreenStatus, RsystemEntry, IADisp, AWGSync, IASource
16150  global COLORcanvas, CANVASwidthIA, CANVASheightIA, RevDate, AWGAMode, AWGAShape, AWGBMode, AWG_2X
16151  global FFTwindow, CutDC, ColorMode, ResScale, GainCorEntry, PhaseCorEntry, DisplaySeries
16152  global GRWIA, X0LIA, GRHIA, Y0TIA, IA_Ext_Conf, DeBugMode, SWRev, CapZeroEntry
16153  global NetworkScreenStatus, IASweepSaved, IAGridType
16154  global FrameRefief, BorderSize
16155 
16156  if IAScreenStatus.get() == 0:
16157  IAScreenStatus.set(1)
16158  IADisp.set(1)
16159  IACheckBox()
16160  CutDC.set(1) # set to remove DC
16161  CANVASwidthIA = GRWIA + 2 * X0LIA + int(21.25 * FontSize) # The canvas width
16162  CANVASheightIA = GRHIA + Y0TIA + int(2.25 * FontSize) # The canvas height
16163  AWGAMode.set(0) # Set AWG A to SVMI
16164  AWGAShape.set(18) # Set Shape to Bode Sine
16165  ReMakeAWGwaves()
16166  if AWG_2X.get == 1:
16167  AWGBMode.set(0) # Set AWG B to SVMI
16168  else:
16169  AWGBMode.set(2) # Set AWG B to Hi-Z
16170  BAWGAModeLabel()
16171  BAWGBModeLabel()
16172  AWGSync.set(1) # Set AWGs to run sync
16173  iawindow = Toplevel()
16174  iawindow.title("Impedance Analyzer " + SWRev + RevDate)
16175  iawindow.protocol("WM_DELETE_WINDOW", DestroyIAScreen)
16176  frame2iar = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
16177  frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
16178 
16179  frame2ia = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
16180  frame2ia.pack(side=TOP, expand=YES, fill=BOTH)
16181 
16182  IAca = Canvas(frame2ia, width=CANVASwidthIA, height=CANVASheightIA, background=COLORcanvas, cursor='cross')
16183  IAca.bind("<Configure>", IACaresize)
16184  IAca.bind("<Return>", DoNothing)
16185  IAca.bind("<space>", onCanvasSpaceBar)
16186  IAca.pack(side=TOP, expand=YES, fill=BOTH)
16187 
16188  # menu buttons
16189  # right side drop down menu buttons
16190  dropmenu = Frame( frame2iar )
16191  dropmenu.pack(side=TOP)
16192  # File menu
16193  IAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
16194  IAFilemenu.menu = Menu(IAFilemenu, tearoff = 0 )
16195  IAFilemenu["menu"] = IAFilemenu.menu
16196  IAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
16197  IAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
16198  IAFilemenu.menu.add_command(label="Run Script", command=RunScript)
16199  IAFilemenu.menu.add_command(label="Save V Cal", command=BSaveCal)
16200  IAFilemenu.menu.add_command(label="Load V Cal", command=BLoadCal)
16201  IAFilemenu.menu.add_command(label="Save Data", command=BSaveDataIA)
16202  IAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenIA)
16203  IAFilemenu.menu.add_command(label="Help", command=BHelp)
16204  IAFilemenu.pack(side=LEFT, anchor=W)
16205  #
16206  IAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
16207  IAOptionmenu.menu = Menu(IAOptionmenu, tearoff = 0 )
16208  IAOptionmenu["menu"] = IAOptionmenu.menu
16209  IAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
16210  IAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
16211  IAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
16212  IAOptionmenu.menu.add_checkbutton(label='Sweep-on', variable=NetworkScreenStatus)
16213  IAOptionmenu.menu.add_checkbutton(label='Save Sweep', variable=IASweepSaved, command=BSaveIASweep)
16214  if DeBugMode == 1:
16215  IAOptionmenu.menu.add_command(label="-Ext Config-", command=donothing)
16216  IAOptionmenu.menu.add_radiobutton(label='1', variable=IA_Ext_Conf, value=0)
16217  IAOptionmenu.menu.add_radiobutton(label='2', variable=IA_Ext_Conf, value=1)
16218  IAOptionmenu.menu.add_command(label="-Meas As-", command=donothing)
16219  IAOptionmenu.menu.add_radiobutton(label='Series', variable=DisplaySeries, value=0)
16220  IAOptionmenu.menu.add_radiobutton(label='Parallel', variable=DisplaySeries, value=1)
16221  IAOptionmenu.menu.add_command(label="-Background-", command=donothing)
16222  IAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
16223  IAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
16224  IAOptionmenu.pack(side=LEFT, anchor=W)
16225  #
16226  rsemenu = Frame( frame2iar )
16227  rsemenu.pack(side=TOP)
16228  rseb2 = Button(rsemenu, text="Stop", style="Stop.TButton", command=BStop)
16229  rseb2.pack(side=RIGHT)
16230  rseb3 = Button(rsemenu, text="Run", style="Run.TButton", command=BStartIA)
16231  rseb3.pack(side=RIGHT)
16232  #
16233  IAFFTwindmenu = Menubutton(frame2iar, text="FFTwindow", style="W11.TButton")
16234  IAFFTwindmenu.menu = Menu(IAFFTwindmenu, tearoff = 0 )
16235  IAFFTwindmenu["menu"] = IAFFTwindmenu.menu
16236  IAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
16237  IAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
16238  IAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
16239  IAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
16240  IAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
16241  IAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
16242  IAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
16243  IAFFTwindmenu.pack(side=TOP)
16244  #
16245  smpmenu = Frame( frame2iar )
16246  smpmenu.pack(side=TOP)
16247  smpb1 = Button(smpmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
16248  smpb1.pack(side=LEFT)
16249  smpb2 = Button(smpmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
16250  smpb2.pack(side=LEFT)
16251  # Temp set source resistance to 1000
16252  rsystem = Frame( frame2iar )
16253  rsystem.pack(side=TOP)
16254  rsystemlab = Label(rsystem, text="Ext Res")
16255  rsystemlab.pack(side=LEFT, anchor=W)
16256  RsystemEntry = Entry(rsystem, width=7, cursor='double_arrow')
16257  RsystemEntry.bind('<Return>', onTextKey)
16258  RsystemEntry.bind('<MouseWheel>', onTextScroll)
16259  RsystemEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16260  RsystemEntry.bind("<Button-5>", onTextScroll)
16261  RsystemEntry.bind('<Key>', onTextKey)
16262  RsystemEntry.pack(side=LEFT, anchor=W)
16263  RsystemEntry.delete(0,"end")
16264  RsystemEntry.insert(4,1000)
16265  # Res Scale Spinbox
16266  ressb = Frame( frame2iar )
16267  ressb.pack(side=TOP)
16268  reslab = Label(ressb, text="Ohms/div ")
16269  reslab.pack(side=LEFT)
16270  ResScale = Spinbox(ressb, width=7, cursor='double_arrow', values=ResScalediv)
16271  ResScale.bind('<MouseWheel>', onSpinBoxScroll)
16272  ResScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16273  ResScale.bind("<Button-5>", onSpinBoxScroll)
16274  ResScale.pack(side=LEFT)
16275  ResScale.delete(0,"end")
16276  ResScale.insert(0,500)
16277  #
16278  GainCor = Frame( frame2iar )
16279  GainCor.pack(side=TOP)
16280  GainCorlab = Label(GainCor, text="Gain Cor dB")
16281  GainCorlab.pack(side=LEFT, anchor=W)
16282  GainCorEntry = Entry(GainCor, width=7, cursor='double_arrow')
16283  GainCorEntry.bind('<Return>', onTextKey)
16284  GainCorEntry.bind('<MouseWheel>', onTextScroll)
16285  GainCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16286  GainCorEntry.bind("<Button-5>", onTextScroll)
16287  GainCorEntry.bind('<Key>', onTextKey)
16288  GainCorEntry.pack(side=LEFT, anchor=W)
16289  GainCorEntry.delete(0,"end")
16290  GainCorEntry.insert(4,0.0)
16291  #
16292  PhaseCor = Frame( frame2iar )
16293  PhaseCor.pack(side=TOP)
16294  PhaseCorlab = Label(PhaseCor, text="Phase Cor")
16295  PhaseCorlab.pack(side=LEFT, anchor=W)
16296  PhaseCorEntry = Entry(PhaseCor, width=7, cursor='double_arrow')
16297  PhaseCorEntry.bind('<Return>', onTextKey)
16298  PhaseCorEntry.bind('<MouseWheel>', onTextScroll)
16299  PhaseCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16300  PhaseCorEntry.bind("<Button-5>", onTextScroll)
16301  PhaseCorEntry.bind('<Key>', onTextKey)
16302  PhaseCorEntry.pack(side=LEFT, anchor=W)
16303  PhaseCorEntry.delete(0,"end")
16304  PhaseCorEntry.insert(4,0.0)
16305  #
16306  capofflab = Label(frame2iar, text="Capacitance Offset")
16307  capofflab.pack(side=TOP)
16308  CapZero = Frame( frame2iar )
16309  CapZero.pack(side=TOP)
16310  CapZerobutton = Button(CapZero, text="Zero", style="W4.TButton", command=IACapZero)
16311  CapZerobutton.pack(side=LEFT, anchor=W)
16312  CapResetbutton = Button(CapZero, text="Reset", style="W5.TButton", command=IACapReset)
16313  CapResetbutton.pack(side=LEFT, anchor=W)
16314  CapZeroEntry = Entry(CapZero, width=6, cursor='double_arrow')
16315  CapZeroEntry.bind('<Return>', onTextKey)
16316  CapZeroEntry.bind('<MouseWheel>', onTextScroll)
16317  CapZeroEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16318  CapZeroEntry.bind("<Button-5>", onTextScroll)
16319  CapZeroEntry.bind('<Key>', onTextKey)
16320  CapZeroEntry.pack(side=LEFT, anchor=W)
16321  CapZeroEntry.delete(0,"end")
16322  CapZeroEntry.insert(4,0.0)
16323  #
16324  srclab = Label(frame2iar, text="Source")
16325  srclab.pack(side=TOP)
16326  extsrc1 = Radiobutton(frame2iar, text="Internal", variable=IASource, value=0, command=IASourceSet)
16327  extsrc1.pack(side=TOP)
16328  extsrc2 = Radiobutton(frame2iar, text="External", variable=IASource, value=1, command=IASourceSet)
16329  extsrc2.pack(side=TOP)
16330  #
16331  gridmenu = Frame( frame2iar )
16332  gridmenu.pack(side=TOP)
16333  iagrid1= Radiobutton(frame2iar, text="Polar Grid", variable=IAGridType, value=0) #, command=IAGridSet)
16334  iagrid1.pack(side=TOP)
16335  iagrid2 = Radiobutton(frame2iar, text="Rect Grid", variable=IAGridType, value=1) #, command=IAGridSet)
16336  iagrid2.pack(side=TOP)
16337  #
16338  dismiss1button = Button(frame2iar, text="Dismiss", style="W8.TButton", command=DestroyIAScreen)
16339  dismiss1button.pack(side=TOP)
16340  # add ADI logo
16341  ADI1 = Label(frame2iar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
16342  ADI1.pack(side=TOP)
16343 #
16344 def DestroyIAScreen():
16345  global iawindow, IAScreenStatus, IAca, IADisp
16346 
16347  IAScreenStatus.set(0)
16348  IADisp.set(0)
16349  IACheckBox()
16350  iawindow.destroy()
16351 #
16352 def BSaveIASweep():
16353  global TIAMline, TIAMRline, IASweepSaved
16354 
16355  if IASweepSaved.get() > 0:
16356  TIAMRline = TIAMline
16357 #
16358 def IACapZero():
16359  global Cseries, CapZeroEntry
16360 
16361  Ctext = ' {0:.1f} '.format(-Cseries * 1E6)
16362  CapZeroEntry.delete(0,"end")
16363  CapZeroEntry.insert(6,Ctext)
16364 #
16365 def IACapReset():
16366  global CapZeroEntry
16367 
16368  CapZeroEntry.delete(0,"end")
16369  CapZeroEntry.insert(4,0.0)
16370 #
16371 def MakeNyquistPlot():
16372  global nqpwindow, NqPca, logo, NqPScreenStatus, NqPDisp
16373  global COLORcanvas, CANVASwidthNqP, CANVASheightNqP, RevDate
16374  global GRWNqP, X0LNqP, GRHNqP, Y0TNqP, DeBugMode, SWRev
16375  global NetworkScreenStatus, NqPSweepSaved
16376  global FrameRefief, BorderSize
16377 
16378  if NqPScreenStatus.get() == 0:
16379  NqPScreenStatus.set(1)
16380  NqPDisp.set(1)
16381  CANVASwidthNqP = GRWNqP + (2 * X0LNqP) # The canvas width
16382  CANVASheightNqP = GRHNqP + Y0TNqP + 10 # The canvas height
16383  nqpwindow = Toplevel()
16384  nqpwindow.title("Nyquist Plot " + SWRev + RevDate)
16385  nqpwindow.protocol("WM_DELETE_WINDOW", DestroyNqPScreen)
16386 
16387  frame2nqp = Frame(nqpwindow, borderwidth=BorderSize, relief=FrameRefief)
16388  frame2nqp.pack(side=TOP, expand=YES, fill=BOTH)
16389 
16390  NqPca = Canvas(frame2nqp, width=CANVASwidthNqP, height=CANVASheightNqP, background=COLORcanvas, cursor='cross')
16391  NqPca.bind("<Configure>", NqPCaresize)
16392  NqPca.bind("<Return>", DoNothing)
16393  NqPca.bind("<space>", onCanvasSpaceBar)
16394  NqPca.pack(side=TOP, expand=YES, fill=BOTH)
16395 #
16396 def DestroyNqPScreen():
16397  global nqpwindow, NqPScreenStatus, NqPca, NqPDisp
16398 
16399  NqPScreenStatus.set(0)
16400  NqPDisp.set(0)
16401  nqpwindow.destroy()
16402 #
16403 def NqPCaresize(event):
16404  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, FontSize
16405 
16406  CANVASwidthNqP = event.width - 4
16407  CANVASheightNqP = event.height - 4
16408  GRWNqP = CANVASwidthNqP - (2 * X0LNqP) # new grid width
16409  GRHNqP = CANVASheightNqP - Y0TNqP - int(1.25 * FontSize) # 10 new grid height
16410  UpdateNqPAll()
16411 
16413 def MakeNqPScreen():
16414  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, COLORtrace1
16415  global COLORgrid, GridWidth, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
16416  global FSweepAdB, FSweepBdB, FSweepBPh, FSweepAPh, ShowMathBP, NqPline, Two_X_Sample, TRACEwidth
16417  global Vdiv, FBins, FStep
16418  global FontSize
16419 
16420  # Delete all items on the canvas
16421  NqPca.delete(ALL) # remove all items
16422  SmoothBool = SmoothCurvesBP.get()
16423  # Draw circular grid lines
16424  i = 1
16425  xcenter = GRWNqP/2
16426  ycenter = GRHNqP/2
16427  Radius = (GRWNqP-X0LNqP)/(1 + Vdiv.get() * 2) # 11
16428  dBperPixel = float(DBdivlist[DBdivindexBP.get()])/Radius
16429  TRadius = Radius * Vdiv.get() # 5
16430  x1 = X0LNqP
16431  x2 = X0LNqP + GRWNqP
16432  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
16433  while (i <= Vdiv.get()):
16434  x0 = xcenter - ( i * Radius )
16435  x1 = xcenter + ( i * Radius )
16436  y0 = ycenter - ( i * Radius )
16437  y1 = ycenter + ( i * Radius )
16438  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
16439  NqPca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
16440  NqPca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
16441  NqPca.create_text(xright, y0, text=str(dBaxis_value), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
16442  #
16443  i = i + 1
16444  NqPca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
16445  NqPca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
16446  RAngle = math.radians(45)
16447  y = TRadius*math.sin(RAngle)
16448  x = TRadius*math.cos(RAngle)
16449  NqPca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16450  NqPca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16451  NqPca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
16452  NqPca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
16453  NqPca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
16454  NqPca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
16455  # xcenter = xcenter + (DBlevelBP.get()/dBperPixel)
16456 # Draw traces
16457  NqPline = []
16458  if len(FSweepAdB) > 4:
16459  for index in range(len(FSweepAdB)): # while n < len(FStep):
16460  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
16461  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
16462  else:
16463  F = FBins[int(FStep[0])]
16464  # Mag value
16465  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
16466  dbB = 10 * math.log10(float(FSweepBdB[index]))
16467  if ShowMathBP.get() == 1:
16468  MdB = dbA - dbB
16469  elif ShowMathBP.get() == 2:
16470  MdB = dbB - dbA
16471  MagRadius = (-MdB / dBperPixel) + (DBlevelBP.get()/dBperPixel)
16472  # Phase Value
16473  RelPhase = FSweepBPh[index] - FSweepAPh[index]
16474  if RelPhase > 180:
16475  RelPhase = RelPhase - 360
16476  elif RelPhase < -180:
16477  RelPhase = RelPhase + 360
16478  if Two_X_Sample.get() == 0:
16479  PhErr = 0.0018 * F # calculate phase error due half sample period offset
16480  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
16481  else:
16482  RelPhase = RelPhase # - PhaseOffset2x # - 9.0
16483  y1 = ycenter - MagRadius*math.sin(math.radians(RelPhase))
16484  if y1 > 1500:
16485  y1 = xright
16486  elif y1 < -500:
16487  y1 = ycenter - xright
16488  x1 = xcenter + MagRadius*math.cos(math.radians(RelPhase ))
16489  if x1 > 1500:
16490  x1 = xright
16491  elif x1 < -500:
16492  x1 = xcenter - xright
16493  NqPline.append(x1)
16494  NqPline.append(y1)
16495  NqPca.create_line(NqPline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
16496 #
16497 def MakeNicPlot():
16498  global NiCScreenStatus, NiCDisp
16499  global nicwindow, NiCca, logo, SWRev
16500  global COLORcanvas, CANVASwidthNic, CANVASheightNic, RevDate
16501  global GRWNiC, X0LNiC, GRHNiC, Y0TNiC, DeBugMode
16502  global NetworkScreenStatus, NiCSweepSaved
16503  global FrameRefief, BorderSize
16504 
16505  if NiCScreenStatus.get() == 0:
16506  NiCScreenStatus.set(1)
16507  NiCDisp.set(1)
16508  CANVASwidthNic = GRWNiC + 18 + X0LNiC # The canvas width
16509  CANVASheightNic = GRHNiC + 60 # The canvas height
16510  nicwindow = Toplevel()
16511  nicwindow.title("Nichols Plot " + SWRev + RevDate)
16512  nicwindow.protocol("WM_DELETE_WINDOW", DestroyNiCScreen)
16513 
16514  frame2nic = Frame(nicwindow, borderwidth=BorderSize, relief=FrameRefief)
16515  frame2nic.pack(side=TOP, expand=YES, fill=BOTH)
16516 
16517  NiCca = Canvas(frame2nic, width=CANVASwidthNic, height=CANVASheightNic, background=COLORcanvas, cursor='cross')
16518  NiCca.bind("<Configure>", NiCCaresize)
16519  NiCca.bind("<Return>", DoNothing)
16520  NiCca.bind("<space>", onCanvasSpaceBar)
16521  NiCca.pack(side=TOP, expand=YES, fill=BOTH)
16522 #
16523 def DestroyNiCScreen():
16524  global nicwindow, NiCScreenStatus, NiCca, NiCDisp
16525 
16526  NiCScreenStatus.set(0)
16527  NiCDisp.set(0)
16528  nicwindow.destroy()
16529 #
16530 def NiCCaresize(event):
16531  global NiCca, GRWNiC, XOLNiC, GRHNiC, Y0TNiC, CANVASwidthNic, CANVASheightNic, FontSize
16532 
16533  CANVASwidthNic = event.width - 4
16534  CANVASheightNic = event.height - 4
16535  GRWNiC = CANVASwidthNic - int(2.25 * FontSize) - X0LNiC # 18 new grid width
16536  GRHNiC = CANVASheightNic - int(7.5 * FontSize) # 60 new grid height
16537  UpdateNiCAll()
16538 
16540 def MakeNiCScreen():
16541  global NiCline, NiCca, CANVASwidthNic, CANVASheightNic, X0LNiC, GRWNiC, Y0TNiC, GRHNiC, X0TNiC
16542  global COLORzeroline, GridWidth, COLORgrid, FSweepAdB, FSweepBdB, Two_X_Sample, ShowMathBP
16543  global FSweepBPh, FSweepAPh, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
16544  global Vdiv, FBins, FStep, PhCenBodeEntry, RelPhaseCenter
16545  global FontSize
16546 
16547  Ymin = Y0TNiC # Minimum position of XY grid (top)
16548  Ymax = Y0TNiC + GRHNiC # Maximum position of XY grid (bottom)
16549  Xmin = X0LNiC # Minimum position of XY grid (left)
16550  Xmax = X0LNiC + GRWNiC # Maximum position of XY grid (right)
16551  try:
16552  Phasecenter = int(PhCenBodeEntry.get())
16553  RelPhaseCenter.set(Phasecenter)
16554  except:
16555  PhCenBodeEntry.delete(0,"end")
16556  PhCenBodeEntry.insert(0,0)
16557  RelPhaseCenter.set(0)
16558  Phasecenter = 0
16559  # Delete all items on the screen
16560  MarkerNum = 0
16561  SmoothBool = SmoothCurvesBP.get()
16562  NiCca.delete(ALL) # remove all items
16563  # Draw horizontal grid lines Rel Gain Magnitude
16564  i = 0
16565  x1 = X0LNiC
16566  x2 = X0TNiC = X0LNiC + GRWNiC
16567  mg_siz = GRWNiC/10.0
16568  mg_inc = mg_siz/5.0
16569  DegPerDiv = 360 / 10
16570  while (i < Vdiv.get()+1):
16571  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
16572  y = Y0TNiC + i * GRHNiC/Vdiv.get()
16573  Dline = [x1,y,x2,y]
16574  if dBaxis_value == 0:
16575  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
16576  k = 0
16577  while (k < 10):
16578  l = 1
16579  while (l < 5): # add tick marks
16580  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
16581  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
16582  l = l + 1
16583  k = k + 1
16584  else:
16585  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
16586  dBaxis_label = str(dBaxis_value)
16587  NiCca.create_text(x1-3, y, text=dBaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
16588 
16589  i = i + 1
16590  # Draw vertical grid lines (phase -180 to 180 10 div)
16591  i = 0
16592  y1 = Y0TNiC
16593  y2 = Y0TNiC + GRHNiC
16594  mg_siz = GRHNiC/10.0
16595  mg_inc = mg_siz/5.0
16596  #
16597  while (i < 11):
16598  x = X0LNiC + i * GRWNiC/10.0
16599  Dline = [x,y1,x,y2]
16600  axis_value = Phasecenter - 180 + (i * DegPerDiv)
16601  axis_label = str(axis_value)
16602  if ( axis_value == 0):
16603  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
16604  k = 0
16605  while (k < 10):
16606  l = 1
16607  while (l < 5): # add tick marks
16608  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
16609  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
16610  l = l + 1
16611  k = k + 1
16612  else:
16613  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
16614  NiCca.create_text(x, y2+3, text=axis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
16615  i = i + 1
16616  # Draw traces
16617  # Vertical conversion factors (level dBs) and border limits
16618  Yconv = float(GRHNiC) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
16619  Yc = float(Y0TNiC) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
16620  Xphconv = float(GRWNiC / 360.0) # degrees per pixel
16621  Xp = float(X0LNiC) + Xphconv * 180.0
16622  x1 = X0LNiC + 14
16623  # Horizontal conversion factors (phase deg) and border limits
16624  NiCline = []
16625  if len(FSweepAdB) > 4:
16626  index = 0
16627  for index in range(len(FSweepAdB)): # while n < len(FStep):
16628  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
16629  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
16630  else:
16631  F = FBins[int(FStep[0])]
16632  # Mag value
16633  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
16634  dbB = 10 * math.log10(float(FSweepBdB[index]))
16635  if ShowMathBP.get() == 1:
16636  MdB = dbA - dbB
16637  elif ShowMathBP.get() == 2:
16638  MdB = dbB - dbA
16639  yb = Yc - Yconv * MdB
16640  if (yb < Ymin):
16641  yb = Ymin
16642  if (yb > Ymax):
16643  yb = Ymax
16644  # Phase Value
16645  RelPhase = FSweepBPh[index] - FSweepAPh[index]
16646  RelPhase = RelPhase - Phasecenter
16647  if RelPhase > 180:
16648  RelPhase = RelPhase - 360
16649  elif RelPhase < -180:
16650  RelPhase = RelPhase + 360
16651  if Two_X_Sample.get() == 0:
16652  PhErr = 0.0018 * F # calculate phase error due half sample period offset
16653  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
16654  else:
16655  RelPhase = RelPhase # - PhaseOffset2x
16656  xa = Xp + Xphconv * RelPhase
16657  if (xa < Xmin):
16658  xa = Ymin
16659  if (xa > Xmax):
16660  xa = Xmax
16661  NiCline.append(int(xa + 0.5))
16662  NiCline.append(int(yb + 0.5))
16663  NiCca.create_line(NiCline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
16664 #
16665 def UpdateNqPAll(): # Update Data, trace and screen
16666  global FFTBuffA, FFTBuffB
16667  global SMPfft
16668 
16669  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
16670  return
16671  #MakeNqPTrace() # Update the traces
16672  UpdateNqPScreen() # Update the screen
16673 
16674 def UpdateNqPTrace(): # Update trace and screen
16675 
16676  #MakeNqPTrace() # Update traces
16677  UpdateNqPScreen() # Update the screen
16678 
16679 def UpdateNqPScreen(): # Update screen with trace and text
16680 
16681  MakeNqPScreen() # Update the screen
16682  root.update() # Activate updated screens
16683 #
16684 def UpdateNiCAll(): # Update Data, trace and screen
16685  global FFTBuffA, FFTBuffB
16686  global SMPfft
16687 
16688  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
16689  return
16690  #MakeNiCTrace() # Update the traces
16691  UpdateNiCScreen() # Update the screen
16692 
16693 def UpdateNiCTrace(): # Update trace and screen
16694 
16695  #MakeNiCTrace() # Update traces
16696  UpdateNiCScreen() # Update the screen
16697 
16698 def UpdateNiCScreen(): # Update screen with trace and text
16699 
16700  MakeNiCScreen() # Update the screen
16701  root.update() # Activate updated screens
16702 #
16703 #
16704 def VAtoggle():
16705  global vat_btn
16706 
16707  if vat_btn.config('text')[-1] == 'ON':
16708  vat_btn.config(text='OFF', style="Stop.TButton")
16709  else:
16710  vat_btn.config(text='ON', style="Run.TButton")
16711 #
16712 def VABtoggle():
16713  global vabt_btn
16714 
16715  if vabt_btn.config('text')[-1] == 'ON':
16716  vabt_btn.config(text='OFF', style="Stop.TButton")
16717  else:
16718  vabt_btn.config(text='ON', style="Run.TButton")
16719 #
16720 def VBtoggle():
16721  global vbt_btn
16722 
16723  if vbt_btn.config('text')[-1] == 'ON':
16724  vbt_btn.config(text='OFF', style="Stop.TButton")
16725  else:
16726  vbt_btn.config(text='ON', style="Run.TButton")
16727 #
16728 def IAtoggle():
16729  global iat_btn
16730 
16731  if iat_btn.config('text')[-1] == 'ON':
16732  iat_btn.config(text='OFF', style="Stop.TButton")
16733  else:
16734  iat_btn.config(text='ON', style="Run.TButton")
16735 #
16736 def IBtoggle():
16737  global ibt_btn
16738 
16739  if ibt_btn.config('text')[-1] == 'ON':
16740  ibt_btn.config(text='OFF', style="Stop.TButton")
16741  else:
16742  ibt_btn.config(text='ON', style="Run.TButton")
16743 #
16745  global iapbt_btn
16746 
16747  if iapbt_btn.config('text')[-1] == 'ON':
16748  iapbt_btn.config(text='OFF', style="Stop.TButton")
16749  else:
16750  iapbt_btn.config(text='ON', style="Run.TButton")
16751 #
16752 # ================ Make Phase Ana Window ==========================
16753 def MakePhAWindow():
16754  global phawindow, PhAca, logo, PhAScreenStatus, PhADisp, AWGSync
16755  global COLORcanvas, CANVASwidthPhA, CANVASheightPhA, RevDate, AWGAMode, AWGAShape, AWGBMode
16756  global FFTwindow, CutDC, ColorMode, RefPhase, CHvpdiv, CHipdiv
16757  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, DeBugMode, SWRev, PhAPlotMode
16758  global VScale, IScale, RefphEntry, MuxScreenStatus, AppendPhAData
16759  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, iapbt_btn
16760  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
16761  global FrameRefief, BorderSize
16762 
16763  if PhAScreenStatus.get() == 0:
16764  PhAScreenStatus.set(1)
16765  PhADisp.set(1)
16766  PhACheckBox()
16767  CutDC.set(1) # set to remove DC
16768  CANVASwidthPhA = GRWPhA + 2 * X0LPhA + int(21.25 * FontSize) # The canvas width
16769  CANVASheightPhA = GRHPhA + Y0TPhA + int(2.25 * FontSize) # The canvas height
16770  phawindow = Toplevel()
16771  phawindow.title("Phase Analyzer " + SWRev + RevDate)
16772  phawindow.protocol("WM_DELETE_WINDOW", DestroyPhAScreen)
16773  frame2phar = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
16774  frame2phar.pack(side=RIGHT, expand=NO, fill=BOTH)
16775 
16776  frame2pha = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
16777  frame2pha.pack(side=TOP, expand=YES, fill=BOTH)
16778 
16779  PhAca = Canvas(frame2pha, width=CANVASwidthPhA, height=CANVASheightPhA, background=COLORcanvas, cursor='cross')
16780  PhAca.bind("<Configure>", PhACaresize)
16781  PhAca.bind("<Return>", DoNothing)
16782  PhAca.bind("<space>", onCanvasSpaceBar)
16783  PhAca.pack(side=TOP, expand=YES, fill=BOTH)
16784 
16785  if MuxScreenStatus.get() == 0:
16786  RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
16787  else:
16788  RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
16789  # menu buttons
16790  # right side drop down menu buttons
16791  dropmenu = Frame( frame2phar )
16792  dropmenu.pack(side=TOP)
16793  # File menu
16794  PhAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
16795  PhAFilemenu.menu = Menu(PhAFilemenu, tearoff = 0 )
16796  PhAFilemenu["menu"] = PhAFilemenu.menu
16797  PhAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
16798  PhAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
16799  PhAFilemenu.menu.add_command(label="Run Script", command=RunScript)
16800  PhAFilemenu.menu.add_command(label="Save Data", command=BSavePhAData)
16801  PhAFilemenu.menu.add_checkbutton(label=' - Append', variable=AppendPhAData)
16802  PhAFilemenu.menu.add_command(label="Plot From File", command=PlotPhAFromFile)
16803  PhAFilemenu.menu.add_radiobutton(label=' - Vectors', variable=PhAPlotMode, value=0)
16804  PhAFilemenu.menu.add_radiobutton(label=' - Outline', variable=PhAPlotMode, value=1)
16805  PhAFilemenu.menu.add_command(label="Help", command=BHelp)
16806  PhAFilemenu.pack(side=LEFT, anchor=W)
16807  #
16808  PhAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
16809  PhAOptionmenu.menu = Menu(PhAOptionmenu, tearoff = 0 )
16810  PhAOptionmenu["menu"] = PhAOptionmenu.menu
16811  PhAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
16812  PhAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
16813  PhAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
16814 
16815  PhAOptionmenu.menu.add_command(label="-Background-", command=donothing)
16816  PhAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
16817  PhAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
16818  PhAOptionmenu.pack(side=LEFT, anchor=W)
16819  #
16820  rsphmenu = Frame( frame2phar )
16821  rsphmenu.pack(side=TOP)
16822  rsphb2 = Button(rsphmenu, text="Stop", style="Stop.TButton", command=BStop)
16823  rsphb2.pack(side=RIGHT)
16824  rsphb3 = Button(rsphmenu, text="Run", style="Run.TButton", command=BStart)
16825  rsphb3.pack(side=RIGHT)
16826  #
16827  PhAFFTwindmenu = Menubutton(frame2phar, text="FFTwindow", style="W11.TButton")
16828  PhAFFTwindmenu.menu = Menu(PhAFFTwindmenu, tearoff = 0 )
16829  PhAFFTwindmenu["menu"] = PhAFFTwindmenu.menu
16830  PhAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
16831  PhAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
16832  PhAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
16833  PhAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
16834  PhAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
16835  PhAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
16836  PhAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
16837  PhAFFTwindmenu.pack(side=TOP)
16838  #
16839  FFTwindow.set(6) # default to Flat top window (6)
16840  #
16841  smphmenu = Frame( frame2phar )
16842  smphmenu.pack(side=TOP)
16843  smphb1 = Button(smphmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
16844  smphb1.pack(side=LEFT)
16845  smphb2 = Button(smphmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
16846  smphb2.pack(side=LEFT)
16847  #
16848  refph = Frame( frame2phar )
16849  refph.pack(side=TOP)
16850  refphlab = Label(refph, text="Ref Phase")
16851  refphlab.pack(side=LEFT, anchor=W)
16852  RefphEntry = Spinbox(refph, width=5, cursor='double_arrow', values=RefPhase)
16853  RefphEntry.bind('<MouseWheel>', onSpinBoxScroll)
16854  RefphEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16855  RefphEntry.bind("<Button-5>", onSpinBoxScroll)
16856  RefphEntry.pack(side=LEFT, anchor=W)
16857  RefphEntry.delete(0,"end")
16858  RefphEntry.insert(0,"CA-V")
16859  vatb = Frame( frame2phar )
16860  vatb.pack(side=TOP)
16861  vatblab = Label(vatb, text="CA-V ")
16862  vatblab.pack(side=LEFT)
16863  vat_btn = Button(vatb, text="OFF", style="Stop.TButton", width=4, command=VAtoggle)
16864  vat_btn.pack(side=LEFT)
16865  vbtb = Frame( frame2phar )
16866  vbtb.pack(side=TOP)
16867  if MuxScreenStatus.get() == 0:
16868  #RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
16869  vbtblab = Label(vbtb, text="CB-V ")
16870  vbtblab.pack(side=LEFT)
16871  vbt_btn = Button(vbtb, text="OFF", style="Stop.TButton", width=4, command=VBtoggle)
16872  vbt_btn.pack(side=LEFT)
16873  vabtb = Frame( frame2phar )
16874  vabtb.pack(side=TOP)
16875  vabtblab = Label(vabtb, text="CA-B V ")
16876  vabtblab.pack(side=LEFT)
16877  vabt_btn = Button(vabtb, text="OFF", style="Stop.TButton", width=4, command=VABtoggle)
16878  vabt_btn.pack(side=LEFT)
16879  else:
16880  #RefphEntry.configure(state=DISABLED)
16881  #RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
16882  amuxlab = Label(frame2phar, text="Analog Mux In")
16883  amuxlab.pack(side=TOP)
16884  phbt1 = Checkbutton(frame2phar, text='CB-A ', style="Strace2.TCheckbutton", variable=ShowPB_A)
16885  phbt1.pack(side=TOP)
16886  phbt2 = Checkbutton(frame2phar, text='CB-B ', style="Strace6.TCheckbutton", variable=ShowPB_B) #, command=TraceSelectADC_Mux)
16887  phbt2.pack(side=TOP)
16888  phbt3 = Checkbutton(frame2phar, text='CB-C ', style="Strace7.TCheckbutton", variable=ShowPB_C) #, command=TraceSelectADC_Mux)
16889  phbt3.pack(side=TOP)
16890  phbt4 = Checkbutton(frame2phar, text='CB-D ', style="Strace4.TCheckbutton", variable=ShowPB_D) #, command=TraceSelectADC_Mux)
16891  phbt4.pack(side=TOP)
16892 #
16893  # Voltage Scale Spinbox
16894  vssb = Frame( frame2phar )
16895  vssb.pack(side=TOP)
16896  vslab = Label(vssb, text="Volts/div ")
16897  vslab.pack(side=LEFT)
16898  VScale = Spinbox(vssb, width=7, cursor='double_arrow', values=CHvpdiv)
16899  VScale.bind('<MouseWheel>', onSpinBoxScroll)
16900  VScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16901  VScale.bind("<Button-5>", onSpinBoxScroll)
16902  VScale.pack(side=LEFT)
16903  VScale.delete(0,"end")
16904  VScale.insert(0,0.5)
16905  #
16906  iatb = Frame( frame2phar )
16907  iatb.pack(side=TOP)
16908  iatblab = Label(iatb, text="CA-I ")
16909  iatblab.pack(side=LEFT)
16910  iat_btn = Button(iatb, text="OFF", style="Stop.TButton", width=4, command=IAtoggle)
16911  iat_btn.pack(side=LEFT)
16912  ibtb = Frame( frame2phar )
16913  ibtb.pack(side=TOP)
16914  ibtblab = Label(ibtb, text="CB-I ")
16915  ibtblab.pack(side=LEFT)
16916  ibt_btn = Button(ibtb, text="OFF", style="Stop.TButton", width=4, command=IBtoggle)
16917  ibt_btn.pack(side=LEFT)
16918  iabtb = Frame( frame2phar )
16919  iabtb.pack(side=TOP)
16920  iapbbtblab = Label(iabtb, text="CA+B I ")
16921  iapbbtblab.pack(side=LEFT)
16922  iapbt_btn = Button(iabtb, text="OFF", style="Stop.TButton", width=4, command=IApBtoggle)
16923  iapbt_btn.pack(side=LEFT)
16924  # Current Scale Spinbox
16925  issb = Frame( frame2phar )
16926  issb.pack(side=TOP)
16927  islab = Label(issb, text="mA/div ")
16928  islab.pack(side=LEFT)
16929  IScale = Spinbox(issb, width=7, cursor='double_arrow', values=CHipdiv)
16930  IScale.bind('<MouseWheel>', onSpinBoxScroll)
16931  IScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16932  IScale.bind("<Button-5>", onSpinBoxScroll)
16933  IScale.pack(side=LEFT)
16934  IScale.delete(0,"end")
16935  IScale.insert(0,10.0)
16936 
16937  dismiss1button = Button(frame2phar, text="Dismiss", style="W8.TButton", command=DestroyPhAScreen)
16938  dismiss1button.pack(side=TOP)
16939  # add ADI logo
16940  ADI1 = Label(frame2phar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
16941  ADI1.pack(side=TOP)
16942 #
16943 # Destroy Phase Analizer window
16944 def DestroyPhAScreen():
16945  global phawindow, PhAScreenStatus, PhAca, PhADisp
16946 
16947  PhAScreenStatus.set(0)
16948  PhADisp.set(0)
16949  PhACheckBox()
16950  phawindow.destroy()
16951 #
16952 # Resize Phase Analizer window
16953 def PhACaresize(event):
16954  global PhAca, GRWPhA, XOLPhA, GRHPhA, Y0TPhA, CANVASwidthPhA, CANVASheightPhA, FontSize
16955 
16956  CANVASwidthPhA = event.width - 4
16957  CANVASheightPhA = event.height - 4
16958  GRWPhA = CANVASwidthPhA - (2 * X0LPhA) - int(21.25 * FontSize) # 170 new grid width
16959  GRHPhA = CANVASheightPhA - Y0TPhA - int(2.25 * FontSize) # 10 new grid height
16960  UpdatePhAAll()
16961 #
16962 def UpdatePhAAll(): # Update Data, trace and screen
16963 
16964  MakePhATrace() # Update the traces
16965  UpdatePhAScreen() # Update the screen
16966 
16967 def UpdatePhATrace(): # Update trace and screen
16968  MakePhATrace() # Update traces
16969  UpdatePhAScreen() # Update the screen
16970 
16971 def UpdatePhAScreen(): # Update screen with trace and text
16972  MakePhAScreen() # Update the screen
16973  root.update() # Activate updated screens
16974 #
16975 # Place holder
16976 def MakePhATrace(): # Update the grid and trace
16977  global VAresult, VBresult, IAresult, IBresult, VABresult, IABresult, PhaseIA, PhaseIB, PhaseVA, PhaseVB, PhaseVAB, PhaseIAB
16978  global VMAresult, VMBresult, VMCresult, VMDresult, PhaseVMD, PhaseVMA, PhaseVMB, PhaseVMC
16979  global PeakVA, PeakVB, PeakIA, PeakIB, PeakVAB, PeakIAB
16980  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16981  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16982  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB, PeakphaseVAB, PeakphaseIAB
16983  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
16984  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
16985  global GRHPhA # Screenheight
16986  global GRWPhA # Screenwidth
16987  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
16988  global STARTsample, STOPsample, LoopNum, FSweepMode
16989  global TRACEmode, Two_X_Sample, MuxScreenStatus, MuxChan, ChopMuxMode
16990  global Vdiv # Number of vertical divisions
16991  global X0LPhA # Left top X value
16992  global Y0TPhA # Left top Y value
16993 
16994  # Set the TRACEsize variable
16995  if len(VAresult) < 32:
16996  return
16997  TRACEsize = len(VAresult) # Set the trace length
16998  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
16999  # Horizontal conversion factors (frequency Hz) and border limits
17000  STARTsample = 0 # First sample in FFTresult[] that is used
17001  STARTsample = int(math.ceil(STARTsample)) # First within screen range
17002  if Two_X_Sample.get() == 0:
17003  STOPsample = 45000 / Fsample # Last sample in FFTresult that is used
17004  else:
17005  STOPsample = 90000 / Fsample
17006  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
17007 #
17008 
17009  MAXsample = TRACEsize # Just an out of range check
17010  if STARTsample > (MAXsample - 1):
17011  STARTsample = MAXsample - 1
17012 
17013  if STOPsample > MAXsample:
17014  STOPsample = MAXsample
17015 
17016  n = STARTsample +1
17017  PeakVA = PeakVB = PeakIA = PeakIB = PeakVAB = PeakIAB = 0.0
17018  PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = PeakfreqIAB = F = n * Fsample
17019  PeakphaseVA = PhaseVA[n]
17020  if MuxScreenStatus.get() == 0:
17021  PeakphaseVB = PhaseVB[n]
17022  else:
17023  PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
17024  PeakphaseIA = PhaseIA[n]
17025  PeakphaseIB = PhaseIB[n]
17026  PeakphaseIAB = PhaseIAB[n]
17027  PeakSampleVB = PeakSampleVA = PeakSampleIA = PeakSampleIB = n
17028  PeakSampleVMA = PeakSampleVMB = PeakSampleVMC = PeakSampleVMD = n
17029  if MuxChan == 0 or ChopMuxMode.get() > 0: #
17030  PeakVMA = 0
17031  PeakphaseVMA = PhaseVMA[n]
17032  PeakSampleVMA = 0
17033  PeakfreqVMA = PeakfreqVA
17034  if MuxChan == 1 or ChopMuxMode.get() > 0: #
17035  PeakVMB = 0
17036  PeakphaseVMB = PhaseVMB[n]
17037  PeakSampleVMB = 0
17038  PeakfreqVMB = PeakfreqVA
17039  if MuxChan == 2 or ChopMuxMode.get() > 0: #
17040  PeakVMC = 0
17041  PeakphaseVMC = PhaseVMC[n]
17042  PeakSampleVMC = 0
17043  PeakfreqVMC = PeakfreqVA
17044  if MuxChan == 3 or ChopMuxMode.get() > 0: #
17045  PeakVMD = 0
17046  PeakphaseVMD = PhaseVMD[n]
17047  PeakSampleVMD = 0
17048  PeakfreqVMD = PeakfreqVA
17049 
17050  while n <= STOPsample: # search for peaks
17051  F = n * Fsample
17052  try:
17053  VA = float(VAresult[n]) #
17054  except:
17055  VA = 0.0
17056  if VA > PeakVA:
17057  PeakVA = VA
17058  PeakfreqVA = F
17059  PeakphaseVA = PhaseVA[n]
17060  PeakSampleVA = n
17061 
17062  if MuxScreenStatus.get() == 0:
17063  try:
17064  VAB = float(VABresult[n]) #
17065  except:
17066  VAB = 0.0
17067  if VAB > PeakVAB:
17068  PeakVAB = VAB
17069  PeakfreqVAB = F
17070  PeakphaseVAB = PhaseVAB[n]
17071  PeakSampleVAB = n
17072 
17073  try:
17074  VB = float(VBresult[n]) #
17075  except:
17076  VB = 0.0
17077  if VB > PeakVB:
17078  PeakVB = VB
17079  PeakfreqVB = F
17080  PeakphaseVB = PhaseVB[n]
17081  PeakSampleVB = n
17082  else:
17083  if MuxChan == 0 or ChopMuxMode.get() > 0: #
17084  try:
17085  VMA = float(VMAresult[n]) #
17086  except:
17087  VMA = 0.0
17088  if VMA > PeakVMA:
17089  PeakVMA = VMA
17090  PeakfreqVMA = F
17091  PeakphaseVMA = PhaseVMA[n]
17092  PeakSampleVMA = n
17093  if MuxChan == 1 or ChopMuxMode.get() > 0: #
17094  try:
17095  VMB = float(VMBresult[n]) #
17096  except:
17097  VMB = 0.0
17098  if VMB > PeakVMB:
17099  PeakVMB = VMB
17100  PeakfreqVMB = F
17101  PeakphaseVMB = PhaseVMB[n]
17102  PeakSampleVMB = n
17103  if MuxChan == 2 or ChopMuxMode.get() > 0: #
17104  try:
17105  VMC = float(VMCresult[n]) #
17106  except:
17107  VMC = 0.0
17108  if VMC > PeakVMC:
17109  PeakVMC = VMC
17110  PeakfreqVMC = F
17111  PeakphaseVMC = PhaseVMC[n]
17112  PeakSampleVMC = n
17113  if MuxChan == 3 or ChopMuxMode.get() > 0: #
17114  try:
17115  VMD = float(VMDresult[n]) #
17116  except:
17117  VMD = 0.0
17118  if VMD > PeakVMD:
17119  PeakVMD = VMD
17120  PeakfreqVMD = F
17121  PeakphaseVMD = PhaseVMD[n]
17122  PeakSampleVMD = n
17123  try:
17124  IA = float(IAresult[n]) #
17125  except:
17126  IA = 0.0
17127  if IA > PeakIA:
17128  PeakIA = IA
17129  PeakfreqIA = F
17130  PeakphaseIA = PhaseIA[n]
17131  PeakSampleIA = n
17132 
17133  try:
17134  IB = float(IBresult[n]) #
17135  except:
17136  IB = 0.0
17137  if IB > PeakIB:
17138  PeakIB = IB
17139  PeakfreqIB = F
17140  PeakphaseIB = PhaseIB[n]
17141  PeakSampleIB = n
17142 
17143  try:
17144  IAB = float(IABresult[n]) #
17145  except:
17146  IAB = 0.0
17147  if IAB > PeakIAB:
17148  PeakIAB = IAB
17149  PeakfreqIAB = F
17150  PeakphaseIAB = PhaseIAB[n]
17151  PeakSampleIAB = n
17152 
17153  n = n + 1
17154 
17155  # Check to see that V, Vnux and I peaks are in same frequency bin?
17156  if PeakSampleVA != PeakSampleIA:
17157  PeakphaseIA = PhaseIA[PeakSampleVA]
17158  PeakIA = IAresult[PeakSampleVA]
17159  if PeakSampleVB != PeakSampleIB and MuxScreenStatus.get() == 0:
17160  PeakphaseIB = PhaseIB[PeakSampleVB]
17161  PeakIB = IBresult[PeakSampleVB]
17162  if MuxScreenStatus.get() > 0:
17163  if PeakSampleVA != PeakSampleVMA:
17164  try:
17165  PeakphaseVMA = PhaseVMA[PeakSampleVA]
17166  PeakVMA = float(VMAresult[PeakSampleVA])
17167  except:
17168  donothing()
17169  if PeakSampleVA != PeakSampleVMB:
17170  try:
17171  PeakphaseVMB = PhaseVMB[PeakSampleVA]
17172  PeakVMB = float(VMBresult[PeakSampleVA])
17173  except:
17174  donothing()
17175  if PeakSampleVA != PeakSampleVMC:
17176  try:
17177  PeakphaseVMC = PhaseVMC[PeakSampleVA]
17178  PeakVMC = float(VMCresult[PeakSampleVA])
17179  except:
17180  donothing()
17181  if PeakSampleVA != PeakSampleVMD:
17182  try:
17183  PeakphaseVMD = PhaseVMD[PeakSampleVA]
17184  PeakVMD = float(VMDresult[PeakSampleVA])
17185  except:
17186  donothing()
17187 #
17188 # Draw the Phase Analyzer screen
17189 def MakePhAScreen(): # Update the screen with traces and text
17190  global PeakVA, PeakVB, PeakIA, PeakIB, PeakVAB, PeakIAB
17191  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
17192  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB, PeakphaseVAB, PeakphaseIAB
17193  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
17194  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
17195  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
17196  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
17197  global CMAphase, CMBphase, CMCphase, CMDphase
17198  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth
17199  global COLORsignalband, COLORtext, COLORgrid # The colors
17200  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
17201  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
17202  global X0LPhA # Left top X value
17203  global Y0TPhA # Left top Y value
17204  global GRWPhA # Screenwidth
17205  global GRHPhA # Screenheight
17206  global FontSize, MuxScreenStatus, MuxChan, Mulx, ChopMuxMode
17207  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
17208  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
17209  global SMPfft # number of FFT samples
17210  global TRACEaverage # Number of traces for averageing
17211  global FreqTraceMode # 1 normal 2 max 3 average
17212  global Vdiv, VScale, IScale # Number of vertical divisions
17213  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, iapbt_btn
17214  global AWGBMode, AWGBIOMode, ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
17215  global ShowC1_V, ShowC2_V, ShowC1_I, ShowC2_I, CHA_RC_HP, CHB_RC_HP
17216  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
17217  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
17218  global InOffA, InGainA, InOffB, InGainB
17219  global CurOffA, CurOffB, CurGainA, CurGainB
17220  # Analog Mux channel measurement variables
17221  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
17222  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
17223  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
17224  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
17225  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
17226  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
17227  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
17228  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
17229  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
17230  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
17231  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
17232  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
17233 
17234  # Delete all items on the screen
17235  PhAca.delete(ALL) # remove all items
17236  # SmoothBool = SmoothCurvesBP.get()
17237  # Draw circular grid lines
17238  i = 1
17239  xcenter = GRWPhA/2
17240  ycenter = (GRHPhA/2) + 14
17241  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
17242  VoltsperPixel = float(VScale.get())/Radius
17243  mAperPixel = float(IScale.get())/Radius
17244  TRadius = Radius * Vdiv.get() # 5
17245  x1 = X0LPhA
17246  x2 = X0LPhA + GRWPhA
17247  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
17248  while (i <= Vdiv.get()):
17249  x0 = xcenter - ( i * Radius )
17250  x1 = xcenter + ( i * Radius )
17251  y0 = ycenter - ( i * Radius )
17252  y1 = ycenter + ( i * Radius )
17253  VTxt = '{0:.2f}'.format(float(VScale.get()) * i)
17254  ITxt = '{0:.2f}'.format(float(IScale.get()) * i)
17255  TOffset = xright+(4*FontSize)
17256  PhAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
17257  PhAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
17258  PhAca.create_text(xright, y0, text=str(VTxt), fill=COLORtrace1, anchor="w", font=("arial", FontSize+2 ))
17259  if iat_btn.config('text')[-1] == 'ON' or ibt_btn.config('text')[-1] == 'ON':
17260  PhAca.create_text(TOffset, y0, text=str(ITxt), fill=COLORtrace3, anchor="w", font=("arial", FontSize+2 ))
17261  #
17262  i = i + 1
17263  PhAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
17264  PhAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
17265  RAngle = math.radians(45)
17266  y = TRadius*math.sin(RAngle)
17267  x = TRadius*math.cos(RAngle)
17268  PhAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
17269  PhAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
17270  PhAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
17271  PhAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
17272  PhAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
17273  PhAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
17274  YBot = y1
17275  # calculate phase error due half sample period offset 0.0018
17276  if Two_X_Sample.get() == 0:
17277  if AWGBMode.get() == 2 or AWGBIOMode.get() > 0:
17278  PhErr = 0.001675 * PeakfreqVA
17279  PhErrMA = PhErr
17280  PhErrMB = PhErr
17281  PhErrMC = PhErr
17282  PhErrMD = PhErr
17283  else:
17284  PhErr = 0.0
17285  PhErrMA = PhErr
17286  PhErrMB = PhErr
17287  PhErrMC = PhErr
17288  PhErrMD = PhErr
17289  else:
17290  PhErr = 0.0
17291  PhErrMA = PhErr
17292  PhErrMB = PhErr
17293  PhErrMC = PhErr
17294  PhErrMD = PhErr
17295  if ChopMuxMode.get() > 0:
17296  PhErrMB = 0.0072 * PeakfreqVMB
17297  PhErrMA = 0.0016 * PeakfreqVMA #
17298  PhErrMD = 0.0054 * PeakfreqVMD
17299  PhErrMC = 0.0016 * PeakfreqVMC #
17300 # Draw traces
17301 #
17302  if RefphEntry.get() == "CA-V":
17303  CAVphase = 0.0
17304  CBVphase = PeakphaseVA - PeakphaseVB + PhErr
17305  CAIphase = PeakphaseVA - PeakphaseIA
17306  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
17307  CABVphase = PeakphaseVA - PeakphaseVAB
17308  CABIphase = PeakphaseVA - PeakphaseIAB
17309  elif RefphEntry.get() == "CB-V":
17310  CBVphase = 0.0
17311  CAVphase = PeakphaseVB - PeakphaseVA - PhErr
17312  CAIphase = PeakphaseVB - PeakphaseIA - PhErr
17313  CBIphase = PeakphaseVB - PeakphaseIB
17314  CABVphase = PeakphaseVB - PeakphaseVAB
17315  CABIphase = PeakphaseVB - PeakphaseIAB
17316  elif RefphEntry.get() == "CA-I":
17317  CAIphase = 0.0
17318  CAVphase = PeakphaseIA - PeakphaseVA
17319  CBVphase = PeakphaseIA - PeakphaseVB + PhErr
17320  CBIphase = PeakphaseIA - PeakphaseIB + PhErr
17321  CABVphase = PeakphaseIA - PeakphaseVAB
17322  CABIphase = PeakphaseIA - PeakphaseIAB
17323  elif RefphEntry.get() == "CB-I":
17324  CBIphase = 0.0
17325  CAVphase = PeakphaseIB - PeakphaseVA - PhErr
17326  CBVphase = PeakphaseIB - PeakphaseVB
17327  CAIphase = PeakphaseIB - PeakphaseIA - PhErr
17328  CABVphase = PeakphaseIB - PeakphaseVAB
17329  CABIphase = PeakphaseIB - PeakphaseIAB
17330  #
17331  if MuxScreenStatus.get() > 0:
17332  CBVphase = 0.0
17333  if RefphEntry.get() == "CA-V":
17334  CAVphase = 0.0
17335  CMAphase = PeakphaseVA - PeakphaseVMA + PhErr
17336  CMBphase = PeakphaseVA - PeakphaseVMB + PhErr
17337  CMCphase = PeakphaseVA - PeakphaseVMC + PhErr
17338  CMDphase = PeakphaseVA - PeakphaseVMD + PhErr
17339  CAIphase = PeakphaseVA - PeakphaseIA
17340  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
17341  elif RefphEntry.get() == "CB-A":
17342  CMAphase = 0.0
17343  CAVphase = PeakphaseVMA - PeakphaseVA + PhErr
17344  CMBphase = PeakphaseVMA - PeakphaseVMB - PhErrMB
17345  CMCphase = PeakphaseVMA - PeakphaseVMC + PhErrMC
17346  CMDphase = PeakphaseVMA - PeakphaseVMD - PhErrMD
17347  CAIphase = PeakphaseVMA - PeakphaseIA
17348  CBIphase = PeakphaseVMA - PeakphaseIB + PhErr
17349  elif RefphEntry.get() == "CB-B":
17350  CMBphase = 0.0
17351  CAVphase = PeakphaseVMB - PeakphaseVA + PhErr
17352  CMAphase = PeakphaseVMB - PeakphaseVMA + PhErrMD
17353  CMCphase = PeakphaseVMB - PeakphaseVMC + PhErrMB
17354  CMDphase = PeakphaseVMB - PeakphaseVMD + PhErrMC
17355  CAIphase = PeakphaseVMB - PeakphaseIA
17356  CBIphase = PeakphaseVMB - PeakphaseIB + PhErr
17357  elif RefphEntry.get() == "CB-C":
17358  CMCphase = 0.0
17359  CAVphase = PeakphaseVMC - PeakphaseVA + PhErr
17360  CMAphase = PeakphaseVMC - PeakphaseVMA + PhErrMC
17361  CMBphase = PeakphaseVMC - PeakphaseVMB - PhErrMB
17362  CMDphase = PeakphaseVMC - PeakphaseVMD - PhErrMD
17363  CAIphase = PeakphaseVMC - PeakphaseIA
17364  CBIphase = PeakphaseVMC - PeakphaseIB + PhErr
17365  elif RefphEntry.get() == "CB-D":
17366  CMDphase = 0.0
17367  CAVphase = PeakphaseVMD - PeakphaseVA + PhErr
17368  CMAphase = PeakphaseVMD - PeakphaseVMA + PhErrMD
17369  CMBphase = PeakphaseVMD - PeakphaseVMB + PhErrMC
17370  CMCphase = PeakphaseVMD - PeakphaseVMC + PhErrMD
17371  CAIphase = PeakphaseVMD - PeakphaseIA
17372  CBIphase = PeakphaseVMD - PeakphaseIB + PhErr
17373 
17374  if CAVphase > 180:
17375  CAVphase = CAVphase - 360
17376  elif CAVphase < -180:
17377  CAVphase = CAVphase + 360
17378  if CBVphase > 180:
17379  CBVphase = CBVphase - 360
17380  elif CBVphase < -180:
17381  CBVphase = CBVphase + 360
17382  if CAIphase > 180:
17383  CAIphase = CAIphase - 360
17384  elif CAIphase < -180:
17385  CAIphase = CAIphase + 360
17386  if CBIphase > 180:
17387  CBIphase = CBIphase - 360
17388  elif CBIphase < -180:
17389  CBIphase = CBIphase + 360
17390  if CABVphase > 180:
17391  CABVphase = CABVphase - 360
17392  elif CABVphase < -180:
17393  CABVphase = CABVphase + 360
17394  if CABIphase > 180:
17395  CABIphase = CABIphase - 360
17396  elif CABIphase < -180:
17397  CABIphase = CABIphase + 360
17398  #
17399  if vat_btn.config('text')[-1] == 'ON':
17400  MagRadius = PeakVA / VoltsperPixel
17401  y1 = ycenter - MagRadius*math.sin(math.radians(CAVphase))
17402  if y1 > 1500:
17403  y1 = xright
17404  elif y1 < -500:
17405  y1 = ycenter - xright
17406  x1 = xcenter + MagRadius*math.cos(math.radians(CAVphase))
17407  if x1 > 1500:
17408  x1 = xright
17409  elif x1 < -500:
17410  x1 = xcenter - xright
17411  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
17412  if MuxScreenStatus.get() == 0:
17413  if vbt_btn.config('text')[-1] == 'ON':
17414  MagRadius = PeakVB / VoltsperPixel
17415  y1 = ycenter - MagRadius*math.sin(math.radians(CBVphase))
17416  if y1 > 1500:
17417  y1 = xright
17418  elif y1 < -500:
17419  y1 = ycenter - xright
17420  x1 = xcenter + MagRadius*math.cos(math.radians(CBVphase))
17421  if x1 > 1500:
17422  x1 = xright
17423  elif x1 < -500:
17424  x1 = xcenter - xright
17425  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
17426  else:
17427  if ShowPB_A.get() > 0:
17428  if CMAphase > 180:
17429  CMAphase = CMAphase - 360
17430  elif CMAphase < -180:
17431  CMAphase = CMAphase + 360
17432  MagRadius = PeakVMA / VoltsperPixel
17433  y1 = ycenter - MagRadius*math.sin(math.radians(CMAphase))
17434  if y1 > 1500:
17435  y1 = xright
17436  elif y1 < -500:
17437  y1 = ycenter - xright
17438  x1 = xcenter + MagRadius*math.cos(math.radians(CMAphase))
17439  if x1 > 1500:
17440  x1 = xright
17441  elif x1 < -500:
17442  x1 = xcenter - xright
17443  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())#
17444  if ShowPB_B.get() > 0:
17445  if CMBphase > 180:
17446  CMBphase = CMBphase - 360
17447  elif CMBphase < -180:
17448  CMBphase = CMBphase + 360
17449  MagRadius = PeakVMB / VoltsperPixel
17450  y1 = ycenter - MagRadius*math.sin(math.radians(CMBphase))
17451  if y1 > 1500:
17452  y1 = xright
17453  elif y1 < -500:
17454  y1 = ycenter - xright
17455  x1 = xcenter + MagRadius*math.cos(math.radians(CMBphase))
17456  if x1 > 1500:
17457  x1 = xright
17458  elif x1 < -500:
17459  x1 = xcenter - xright
17460  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())#
17461  if ShowPB_C.get() > 0:
17462  if CMCphase > 180:
17463  CMCphase = CMCphase - 360
17464  elif CMCphase < -180:
17465  CMCphase = CMCphase + 360
17466  MagRadius = PeakVMC / VoltsperPixel
17467  y1 = ycenter - MagRadius*math.sin(math.radians(CMCphase))
17468  if y1 > 1500:
17469  y1 = xright
17470  elif y1 < -500:
17471  y1 = ycenter - xright
17472  x1 = xcenter + MagRadius*math.cos(math.radians(CMCphase))
17473  if x1 > 1500:
17474  x1 = xright
17475  elif x1 < -500:
17476  x1 = xcenter - xright
17477  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace7, arrow="last", width=TRACEwidth.get())#
17478  if ShowPB_D.get() > 0:
17479  if CMDphase > 180:
17480  CMDphase = CMDphase - 360
17481  elif CMDphase < -180:
17482  CMDphase = CMDphase + 360
17483  MagRadius = PeakVMD / VoltsperPixel
17484  y1 = ycenter - MagRadius*math.sin(math.radians(CMDphase))
17485  if y1 > 1500:
17486  y1 = xright
17487  elif y1 < -500:
17488  y1 = ycenter - xright
17489  x1 = xcenter + MagRadius*math.cos(math.radians(CMDphase))
17490  if x1 > 1500:
17491  x1 = xright
17492  elif x1 < -500:
17493  x1 = xcenter - xright
17494  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())#
17495  if iat_btn.config('text')[-1] == 'ON':
17496  MagRadius = PeakIA / mAperPixel
17497  y1 = ycenter - MagRadius*math.sin(math.radians(CAIphase))
17498  if y1 > 1500:
17499  y1 = xright
17500  elif y1 < -500:
17501  y1 = ycenter - xright
17502  x1 = xcenter + MagRadius*math.cos(math.radians(CAIphase))
17503  if x1 > 1500:
17504  x1 = xright
17505  elif x1 < -500:
17506  x1 = xcenter - xright
17507  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace3, arrow="last", width=TRACEwidth.get())
17508  if ibt_btn.config('text')[-1] == 'ON':
17509  MagRadius = PeakIB / mAperPixel
17510  y1 = ycenter - MagRadius*math.sin(math.radians(CBIphase))
17511  if y1 > 1500:
17512  y1 = xright
17513  elif y1 < -500:
17514  y1 = ycenter - xright
17515  x1 = xcenter + MagRadius*math.cos(math.radians(CBIphase))
17516  if x1 > 1500:
17517  x1 = xright
17518  elif x1 < -500:
17519  x1 = xcenter - xright
17520  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())
17521  if MuxScreenStatus.get() == 0:
17522  # plot VA - VB vector
17523  if vabt_btn.config('text')[-1] == 'ON':
17524  MagRadius = PeakVAB / VoltsperPixel
17525 
17526  y1 = ycenter - MagRadius*math.sin(math.radians(CABVphase))
17527  if y1 > 1500:
17528  y1 = xright
17529  elif y1 < -500:
17530  y1 = ycenter - xright
17531  x1 = xcenter + MagRadius*math.cos(math.radians(CABVphase))
17532  if x1 > 1500:
17533  x1 = xright
17534  elif x1 < -500:
17535  x1 = xcenter - xright
17536  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
17537  # plot IA + IB vector
17538  if iapbt_btn.config('text')[-1] == 'ON':
17539  MagRadius = PeakIAB / mAperPixel
17540 
17541  y1 = ycenter - MagRadius*math.sin(math.radians(CABIphase))
17542  if y1 > 1500:
17543  y1 = xright
17544  elif y1 < -500:
17545  y1 = ycenter - xright
17546  x1 = xcenter + MagRadius*math.cos(math.radians(CABIphase))
17547  if x1 > 1500:
17548  x1 = xright
17549  elif x1 < -500:
17550  x1 = xcenter - xright
17551  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace7, arrow="last", width=TRACEwidth.get())
17552 # display warning if input out of range
17553  if OverRangeFlagA == 1:
17554  x = X0LPhA+GRWPhA+10
17555  y = Y0TPhA+GRHPhA-40
17556  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
17557  PhAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
17558  if OverRangeFlagB == 1:
17559  x = X0LPhA+GRWPhA+10
17560  y = Y0TPhA+GRHPhA-10
17561  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
17562  PhAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
17563 # General information on top of the grid
17564  txt = " Sample rate: " + str(SAMPLErate)
17565  txt = txt + " FFT samples: " + str(SMPfft)
17566  txt = txt + " " + FFTwindowname
17567 
17568  x = X0LPhA
17569  y = 12
17570  idTXT = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
17571  #
17572  x = X0LPhA + GRWPhA + 4
17573  y = 24
17574  if ChopMuxMode.get() == 0:
17575  txt = "CA " + ' {0:.3f} '.format(PeakVA) + " RMS V"
17576  TXT9 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
17577  y = y + 24
17578  if MuxScreenStatus.get() == 0:
17579  txt = "CB " + ' {0:.3f} '.format(PeakVB) + " RMS V"
17580  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
17581  y = y + 24
17582  else:
17583  if ShowPB_A.get() > 0:
17584  txt = "Mux A " + ' {0:.3f} '.format(PeakVMA) + " RMS V"
17585  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
17586  y = y + 24
17587  if ShowPB_B.get() > 0:
17588  txt = "Mux B " + ' {0:.3f} '.format(PeakVMB) + " RMS V"
17589  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
17590  y = y + 24
17591  if ShowPB_C.get() > 0:
17592  txt = "Mux C " + ' {0:.3f} '.format(PeakVMC) + " RMS V"
17593  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
17594  y = y + 24
17595  if ShowPB_D.get() > 0:
17596  txt = "Mux D " + ' {0:.3f} '.format(PeakVMD) + " RMS V"
17597  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
17598  y = y + 24
17599  if vabt_btn.config('text')[-1] == 'ON':
17600  txt = "VA-VB " + ' {0:.3f} '.format(PeakVAB) + " RMS V"
17601  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace5, font=("arial", FontSize+4 ))
17602  y = y + 24
17603  if iat_btn.config('text')[-1] == 'ON':
17604  txt = "CA " + ' {0:.2f} '.format(PeakIA) + " RMS mA"
17605  TXT11 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
17606  y = y + 24
17607  if ibt_btn.config('text')[-1] == 'ON':
17608  txt = "CB " + ' {0:.2f} '.format(PeakIB) + " RMS mA"
17609  TXT12 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
17610  y = y + 24
17611  if iapbt_btn.config('text')[-1] == 'ON':
17612  txt = "IA+IB " + ' {0:.2f} '.format(PeakIAB) + " RMS mA"
17613  TXT12 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
17614  y = y + 24
17615  if ChopMuxMode.get() == 0:
17616  txt = "CA V Phase " + ' {0:.1f} '.format(CAVphase) + " Degrees"
17617  TXT13 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
17618  y = y + 24
17619  if MuxScreenStatus.get() == 0:
17620  txt = "CB V Phase " + ' {0:.1f} '.format(CBVphase) + " Degrees"
17621  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
17622  y = y + 24
17623  else:
17624  if ShowPB_A.get() > 0:
17625  txt = "Mux A Phase " + ' {0:.1f} '.format(CMAphase) + " Degrees"
17626  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
17627  y = y + 24
17628  if ShowPB_B.get() > 0:
17629  txt = "Mux B Phase " + ' {0:.1f} '.format(CMBphase) + " Degrees"
17630  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
17631  y = y + 24
17632  if ShowPB_C.get() > 0:
17633  txt = "Mux C Phase " + ' {0:.1f} '.format(CMCphase) + " Degrees"
17634  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
17635  y = y + 24
17636  if ShowPB_D.get() > 0:
17637  txt = "Mux D Phase " + ' {0:.1f} '.format(CMDphase) + " Degrees"
17638  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
17639  y = y + 24
17640  if vabt_btn.config('text')[-1] == 'ON':
17641  txt = "VA-VB Phase " + ' {0:.1f} '.format(CABVphase) + " Degrees"
17642  TXT13 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace5, font=("arial", FontSize+4 ))
17643  y = y + 24
17644  if iat_btn.config('text')[-1] == 'ON':
17645  txt = "CA I Phase " + ' {0:.1f} '.format(CAIphase) + " Degrees"
17646  TXT15 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
17647  y = y + 24
17648  if ibt_btn.config('text')[-1] == 'ON':
17649  txt = "CB I Phase " + ' {0:.1f} '.format(CBIphase) + " Degrees"
17650  TXT16 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
17651  y = y + 24
17652  if iapbt_btn.config('text')[-1] == 'ON':
17653  txt = "IA+IB Phase " + ' {0:.1f} '.format(CABIphase) + " Degrees"
17654  TXT16 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
17655  y = y + 24
17656  #
17657  if ChopMuxMode.get() == 0:
17658  txt = "CA-V Freq " + ' {0:.1f} '.format(PeakfreqVA) + " Hertz"
17659  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
17660  y = y + 24
17661  else:
17662  txt = "Mux A Freq " + ' {0:.1f} '.format(PeakfreqVMA) + " Hertz"
17663  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
17664  y = y + 24
17665 #
17666  txt = " "
17667 # print time domin measured period and frequency of displayed channels
17668  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
17669  if ETSDisp.get() > 0:
17670  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
17671  else:
17672  FindRisingEdge(VBuffA,VBuffB)
17673  if ShowC1_V.get() == 1:
17674  if MeasAHW.get() == 1:
17675  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
17676  if MeasALW.get() == 1:
17677  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
17678  if MeasADCy.get() == 1:
17679  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
17680  if MeasAPER.get() == 1:
17681  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
17682  if MeasAFREQ.get() == 1:
17683  txt = txt + " CA Freq = "
17684  ChaF = float(CHAfreq*Mulx)
17685  if ChaF < 1000:
17686  V1String = ' {0:.2f} '.format(ChaF)
17687  txt = txt + str(V1String) + " Hz "
17688  if ChaF > 1000 and ChaF < 1000000:
17689  V1String = ' {0:.2f} '.format(ChaF/1000)
17690  txt = txt + str(V1String) + " KHz "
17691  if ChaF > 1000000:
17692  V1String = ' {0:.2f} '.format(ChaF/1000000)
17693  txt = txt + str(V1String) + " MHz "
17694  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
17695  if ShowC2_V.get() == 1:
17696  if MeasBHW.get() == 1:
17697  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
17698  if MeasBLW.get() == 1:
17699  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
17700  if MeasBDCy.get() == 1:
17701  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
17702  if MeasBPER.get() == 1:
17703  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
17704  if MeasBFREQ.get() == 1:
17705  txt = txt + " CB Freq = "
17706  ChaF = float(CHBfreq*Mulx)
17707  if ChaF < 1000:
17708  V1String = ' {0:.2f} '.format(ChaF)
17709  txt = txt + str(V1String) + " Hz "
17710  if ChaF > 1000 and ChaF < 1000000:
17711  V1String = ' {0:.2f} '.format(ChaF/1000)
17712  txt = txt + str(V1String) + " KHz "
17713  if ChaF > 1000000:
17714  V1String = ' {0:.2f} '.format(ChaF/1000000)
17715  txt = txt + str(V1String) + " MHz "
17716  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
17717  if MuxScreenStatus.get() == 0:
17718  if MeasPhase.get() == 1:
17719  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
17720  if MeasDelay.get() == 1:
17721  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
17722 
17723  x = X0LPhA
17724  y = YBot + int(2.5 *FontSize) #
17725  TXT18 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
17726  txt = " "
17727  if ShowC1_V.get() == 1:
17728  # Channel A information
17729  if CHA_RC_HP.get() == 1:
17730  txt = "CHA: HP "
17731  else:
17732  txt = "CHA: "
17733  if MeasDCV1.get() == 1:
17734  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
17735  if MeasMaxV1.get() == 1:
17736  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
17737  if MeasTopV1.get() == 1:
17738  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
17739  if MeasMinV1.get() == 1:
17740  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
17741  if MeasBaseV1.get() == 1:
17742  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
17743  if MeasMidV1.get() == 1:
17744  MidV1 = (MaxV1+MinV1)/2.0
17745  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
17746  if MeasPPV1.get() == 1:
17747  PPV1 = MaxV1-MinV1
17748  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
17749  if MeasRMSV1.get() == 1:
17750  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
17751  if MeasRMSVA_B.get() == 1:
17752  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
17753  if MeasDiffAB.get() == 1:
17754  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
17755  if MeasUserA.get() == 1:
17756  try:
17757  TempValue = eval(UserAString)
17758  V1String = ' {0:.4f} '.format(TempValue)
17759  except:
17760  V1String = "####"
17761  txt = txt + UserALabel + " = " + V1String
17762  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
17763  txt = "CHA: "
17764  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
17765  txt = txt + "CHA: "
17766 
17767  if ShowC1_I.get() == 1:
17768  if MeasDCI1.get() == 1:
17769  V1String = ' {0:.2f} '.format(DCI1)
17770  txt = txt + " AvgI = " + V1String
17771  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
17772  try:
17773  Resvalue = (DCV1/DCI1)*1000
17774  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
17775  except:
17776  txt = txt + " Res = OverRange"
17777  if MeasMaxI1.get() == 1:
17778  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
17779  if MeasMinI1.get() == 1:
17780  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
17781  if MeasMidI1.get() == 1:
17782  MidI1 = (MaxI1+MinI1)/2.0
17783  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
17784  if MeasPPI1.get() == 1:
17785  PPI1 = MaxI1-MinI1
17786  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
17787  if MeasRMSI1.get() == 1:
17788  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
17789 
17790  x = X0LPhA
17791  y = YBot + int(4*FontSize) #
17792  TXT19 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
17793  txt= " "
17794  # Channel B information
17795  if MuxScreenStatus.get() == 1:
17796  txt = "CHB-Mux: "
17797  if Show_CBA.get() > 0:
17798  FindRisingEdge(VBuffA,VBuffMA)
17799  elif Show_CBB.get() > 0:
17800  FindRisingEdge(VBuffA,VBuffMB)
17801  elif Show_CBC.get() > 0:
17802  FindRisingEdge(VBuffA,VBuffMC)
17803  elif Show_CBD.get() > 0:
17804  FindRisingEdge(VBuffA,VBuffMD)
17805  if MeasPhase.get() == 1:
17806  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
17807  if MeasDelay.get() == 1:
17808  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
17809  if MeasUserB.get() == 1:
17810  try:
17811  TempValue = eval(UserBString)
17812  V1String = ' {0:.4f} '.format(TempValue)
17813  except:
17814  V1String = "####"
17815  txt = txt + UserBLabel + " = " + V1String
17816  if ShowC2_V.get() == 1:
17817  if CHB_RC_HP.get() == 1:
17818  txt = "CHB: HP "
17819  else:
17820  txt = "CHB: "
17821  if MeasDCV2.get() == 1:
17822  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
17823  if MeasMaxV2.get() == 1:
17824  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
17825  if MeasTopV2.get() == 1:
17826  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
17827  if MeasMinV2.get() == 1:
17828  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
17829  if MeasBaseV2.get() == 1:
17830  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
17831  if MeasMidV2.get() == 1:
17832  MidV2 = (MaxV2+MinV2)/2.0
17833  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
17834  if MeasPPV2.get() == 1:
17835  PPV2 = MaxV2-MinV2
17836  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
17837  if MeasRMSV2.get() == 1:
17838  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
17839  if MeasDiffBA.get() == 1:
17840  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
17841  if MeasUserB.get() == 1:
17842  try:
17843  TempValue = eval(UserBString)
17844  V1String = ' {0:.4f} '.format(TempValue)
17845  except:
17846  V1String = "####"
17847  txt = txt + UserBLabel + " = " + V1String
17848  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
17849  txt = "CHB: "
17850  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
17851  txt = txt + "CHB: "
17852  if ShowC2_I.get() == 1:
17853  if MeasDCI2.get() == 1:
17854  V1String = ' {0:.2f} '.format(DCI2)
17855  txt = txt + " AvgI = " + V1String
17856  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
17857  try:
17858  Resvalue = (DCV2/DCI2)*1000
17859  R1String = ' {0:.1f} '.format(Resvalue)
17860  txt = txt + " Res = " + R1String
17861  except:
17862  txt = txt + " Res = OverRange"
17863  if MeasMaxI2.get() == 1:
17864  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
17865  if MeasMinI2.get() == 1:
17866  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
17867  if MeasMidI2.get() == 1:
17868  MidI2 = (MaxI2+MinI2)/2.0
17869  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
17870  if MeasPPI2.get() == 1:
17871  PPI2 = MaxI2-MinI2
17872  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
17873  if MeasRMSI2.get() == 1:
17874  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
17875 
17876  x = X0LPhA
17877  y = YBot + int(5.5 *FontSize) #
17878  TXT20 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
17879 #
17880 def BSavePhAData():
17881  global PeakVA, PeakVB, PeakIA, PeakIB
17882  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
17883  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
17884  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
17885  global CMAphase, CMBphase, CMCphase, CMDphase
17886  global MuxScreenStatus, AppendPhAData, PhADatafilename
17887  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
17888  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
17889 
17890  # open file to save data
17891  if AppendPhAData.get() == 0:
17892  PhADatafilename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
17893  DataFile = open(PhADatafilename, 'a')
17894  DataFile.write( 'Amplitude, Phase, @ ' + str(PeakfreqVA) + ' Hertz\n')
17895 
17896  if vat_btn.config('text')[-1] == 'ON':
17897  DataFile.write( str(PeakVA) + ', ' + str(CAVphase) + ', CA-V\n')
17898  if MuxScreenStatus.get() == 0:
17899  if vbt_btn.config('text')[-1] == 'ON':
17900  DataFile.write( str(PeakVB) + ', ' + str(CBVphase) + ', CB-V\n')
17901  else:
17902  if ShowPB_A.get() > 0:
17903  DataFile.write( str(PeakVMA) + ', ' + str(CMAphase) + ', Mux A\n')
17904  if ShowPB_B.get() > 0:
17905  DataFile.write( str(PeakVMB) + ', ' + str(CMBphase) + ', Mux B\n')
17906  if ShowPB_C.get() > 0:
17907  DataFile.write( str(PeakVMC) + ', ' + str(CMCphase) + ', Mux C\n')
17908  if ShowPB_D.get() > 0:
17909  DataFile.write( str(PeakVMD) + ', ' + str(CMDphase) + ', Mux D\n')
17910  if iat_btn.config('text')[-1] == 'ON':
17911  DataFile.write( str(PeakIA) + ', ' + str(CAIphase) + ', CA-I\n')
17912  if ibt_btn.config('text')[-1] == 'ON':
17913  DataFile.write( str(PeakIB) + ', ' + str(CBIphase) + ', CB-I\n')
17914  DataFile.close()
17915 #
17916 def PlotPhAFromFile():
17917  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth, PhAPlotMode
17918  global COLORsignalband, COLORtext, COLORgrid, SmoothCurves # The colors
17919  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
17920  global GRWPhA, GRHPhA, X0LPhA, Vdiv, VScale, IScale
17921 # open file to read data from
17922  filename = askopenfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
17923  i = 1
17924  xcenter = GRWPhA/2
17925  ycenter = (GRHPhA/2) + 14
17926  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
17927  VoltsperPixel = float(VScale.get())/Radius
17928  mAperPixel = float(IScale.get())/Radius
17929  TRadius = Radius * Vdiv.get() # 5
17930  x1 = X0LPhA
17931  x2 = X0LPhA + GRWPhA
17932  PhATrace = []
17933 # Read values from CVS file
17934  try:
17935  CSVFile = open(filename)
17936  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
17937  CSVFile.seek(0)
17938  csv_f = csv.reader(CSVFile, dialect)
17939  for row in csv_f:
17940  try:
17941  PeakMag = float(row[0])
17942  PeakPhase = float(row[1])
17943  if row[2] == "CA-I" or row[2] == "CB-I":
17944  MagRadius = PeakMag / mAperPixel
17945  else:
17946  MagRadius = PeakMag / VoltsperPixel
17947 
17948  y1 = ycenter - MagRadius*math.sin(math.radians(PeakPhase))
17949  if y1 > 1500:
17950  y1 = xright
17951  elif y1 < -500:
17952  y1 = ycenter - xright
17953  x1 = xcenter + MagRadius*math.cos(math.radians(PeakPhase))
17954  if x1 > 1500:
17955  x1 = xright
17956  elif x1 < -500:
17957  x1 = xcenter - xright
17958  if PhAPlotMode.get() == 0:
17959  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
17960  else:
17961  PhATrace.append(x1)
17962  PhATrace.append(y1)
17963  except:
17964  print( 'skipping non-numeric row')
17965  if PhAPlotMode.get() == 1:
17966  PhAca.create_line(PhATrace, fill=COLORtrace5, smooth=SmoothCurves.get(), splinestep=5, width=TRACEwidth.get())
17967  CSVFile.close()
17968  except:
17969  showwarning("WARNING","No such file found or wrong format!")
17970 #
17971 #
17972 def STOREcsvfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
17973  global FFTmemoryA, FFTresultA, SMPfft
17974  global FFTmemoryB, FFTresultB
17975  global PhaseA, PhaseB, freqwindow
17976  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, ShowC1_VdB, ShowC2_VdB
17977 
17978  # Set the TRACEsize variable
17979  if ShowC1_VdB.get() == 1:
17980  TRACEsize = len(FFTresultA) # Set the trace length
17981  elif ShowC2_VdB.get() == 1:
17982  TRACEsize = len(FFTresultB)
17983  if TRACEsize == 0: # If no trace, skip rest of this routine
17984  return()
17985 # ask if save as magnitude or dB
17986  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=freqwindow)
17987  # Make the file name and open it
17988  if dB == 0:
17989  PSD = askyesno("Mag/Root Hz? ","Save Mag in V/sqrt Hz? (yes) or (No):\n", parent=freqwindow)
17990  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
17991  filename = "Spectrum-" + tme
17992  filename = filename + ".csv"
17993  # open file to save data
17994  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
17995  filetypes=[("Comma Separated Values", "*.csv")], parent=freqwindow)
17996  DataFile = open(filename,'a') # Open output file
17997  HeaderString = 'Frequency-#, '
17998  if ShowC1_VdB.get() == 1:
17999  if dB == 1:
18000  HeaderString = HeaderString + 'CA-dB, '
18001  if dB == 0:
18002  HeaderString = HeaderString + 'CA-Mag, '
18003  if ShowC2_VdB.get() == 1:
18004  if dB == 1:
18005  HeaderString = HeaderString + 'CB-dB, '
18006  if dB == 0:
18007  HeaderString = HeaderString + 'CB-Mag, '
18008  if ShowC1_P.get() == 1:
18009  HeaderString = HeaderString + 'Phase A-B, '
18010  if ShowC2_P.get() == 1:
18011  HeaderString = HeaderString + 'Phase B-A, '
18012  HeaderString = HeaderString + '\n'
18013  DataFile.write( HeaderString )
18014 
18015  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
18016  n = 0
18017 
18018  while n < TRACEsize:
18019  F = n * FBinWidth
18020  txt = str(F)
18021  if ShowC1_VdB.get() == 1:
18022  V = 10 * math.log10(float(FFTresultA[n])) #
18023  if dB == 0:
18024  V = 10.0**(V/20.0) # RMS Volts
18025  if PSD == 1:
18026  V = V/math.sqrt(FBinWidth) # per root Hz
18027  txt = txt + "," + str(V)
18028  if ShowC2_VdB.get() == 1:
18029  V = 10 * math.log10(float(FFTresultB[n])) #
18030  if dB == 0:
18031  V = 10.0**(V/20.0)# RMS Volts
18032  if PSD == 1:
18033  V = V/math.sqrt(FBinWidth) # per root Hz
18034  txt = txt + "," + str(V)
18035  if ShowC1_P.get() == 1:
18036  RelPhase = PhaseA[n]-PhaseB[n]
18037  if RelPhase > 180:
18038  RelPhase = RelPhase - 360
18039  elif RelPhase < -180:
18040  RelPhase = RelPhase + 360
18041  txt = txt + "," + str(RelPhase)
18042  if ShowC2_P.get() == 1:
18043  RelPhase = PhaseB[n]-PhaseA[n]
18044  if RelPhase > 180:
18045  RelPhase = RelPhase - 360
18046  elif RelPhase < -180:
18047  RelPhase = RelPhase + 360
18048  txt = txt + "," + str(RelPhase)
18049  txt = txt + "\n"
18050  DataFile.write(txt)
18051  n = n + 1
18052 
18053  DataFile.close() # Close the file
18054 
18056 def MakeFreqScreen(): # Update the screen with traces and text
18057  global CANVASheightF, CANVASwidthF, SmoothCurvesSA
18058  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
18059  global PeakxM, PeakyM, PeakMdb, PeakfreqM
18060  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
18061  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
18062  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM, PeakIndexA, PeakIndexB, Fsample
18063  global COLORgrid # The colors
18064  global COLORsignalband, COLORtext
18065  global COLORtrace1, COLORtrace2
18066  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
18067  global DBdivindex # Index value
18068  global DBdivlist # dB per division list
18069  global DBlevel # Reference level
18070  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
18071  global X0LF # Left top X value
18072  global Y0TF # Left top Y value
18073  global GRWF # Screenwidth
18074  global GRHF # Screenheight
18075  global FontSize
18076  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
18077  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SingleShotSA, HScale, HarmonicMarkers
18078  global SMPfft # number of FFT samples
18079  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
18080  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
18081  global ShowC1_P, ShowC2_P, ShowRA_VdB, ShowRB_VdB, ShowMarker
18082  global ShowRA_P, ShowRB_P, ShowMathSA, FreqDisp, ShowAWGASA, ShowAWGBSA
18083  global ShowFCur, ShowdBCur, FCursor, dBCursor
18084  global T1Fline, T2Fline, T1Pline, T1FRline, T2FRline, TFMline, TFRMline
18085  global T1PRline, T2PRline, TAFline, TBFline
18086  global TRACEaverage # Number of traces for averageing
18087  global FreqTraceMode # 1 normal 2 max 3 average
18088  global Vdiv # Number of vertical divisions
18089 
18090  # Delete all items on the screen
18091  MarkerFreqNum = 0
18092  FBinWidth = float(SAMPLErate / 2.0) / (SMPfft - 1) # Frequency step per sample
18093  Freqca.delete(ALL) # remove all items
18094  try:
18095  StartFrequency = float(StartFreqEntry.get())
18096  except:
18097  StartFreqEntry.delete(0,"end")
18098  StartFreqEntry.insert(0,100)
18099  StartFrequency = 100
18100  try:
18101  StopFrequency = float(StopFreqEntry.get())
18102  except:
18103  StopFreqEntry.delete(0,"end")
18104  StopFreqEntry.insert(0,10000)
18105  StopFrequency = 10000
18106  try:
18107  Phasecenter = int(PhCenFreqEntry.get())
18108  RelPhaseCenter.set(Phasecenter)
18109  except:
18110  PhCenFreqEntry.delete(0,"end")
18111  PhCenFreqEntry.insert(0,0)
18112  RelPhaseCenter.set(0)
18113  Phasecenter = 0
18114  # Draw horizontal grid lines
18115  i = 0
18116  x1 = X0LF
18117  x2 = X0LF + GRWF
18118  if SAVScale.get() == 0: # In dB
18119  while (i <= Vdiv.get()):
18120  y = Y0TF + i * GRHF/Vdiv.get()
18121  Dline = [x1,y,x2,y]
18122  if i == 0 or i == Vdiv.get():
18123  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18124  else:
18125  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18126  Vaxis_value = (DBlevel.get() - (i * DBdivlist[DBdivindex.get()]))
18127  Vaxis_label = str(Vaxis_value)
18128  Freqca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
18129  if ShowC1_P.get() == 1 or ShowC2_P.get() == 1:
18130  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get())))
18131  Vaxis_value = Vaxis_value + Phasecenter
18132  Vaxis_label = str(Vaxis_value)
18133  Freqca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
18134  i = i + 1
18135  else: # In rms V
18136  if SAVScale.get() == 2: # Log Scale
18137  try:
18138  LogVStop = math.log10(SAvertmax)
18139  except:
18140  LogVStop = 0.0
18141  try:
18142  LogVStart = math.log10(SAvertmin)
18143  except:
18144  LogVStart = -10
18145  LogVpixel = (LogVStart - LogVStop) / GRHF
18146  NumDec = LogVStart - LogVStop # number of major grids
18147  Gridpixel = GRHF/NumDec # number of pixels per major grid
18148  V = NumDec
18149  while V <= 0: # Major Grid lines
18150  try:
18151  LogV = math.log10(10**V) # convet to log Volts
18152  y = Y0TF + (LogV/LogVpixel)
18153  except:
18154  y = Y0TF
18155  Dline = [x1,y,x2,y]
18156  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18157  LNum = LogVStop + V
18158  if LNum == 1.0:
18159  axis_label = "10.0"
18160  elif LNum == 0:
18161  axis_label = "1.0"
18162  elif LNum == -1:
18163  axis_label = "100mV"
18164  elif LNum == -2:
18165  axis_label = "10mV"
18166  elif LNum == -3:
18167  axis_label = "1mV"
18168  elif LNum == -4:
18169  axis_label = "100uV"
18170  elif LNum == -5:
18171  axis_label = "10uV"
18172  elif LNum == -6:
18173  axis_label = "1uV"
18174  elif LNum == -7:
18175  axis_label = "100nV"
18176  elif LNum == -8:
18177  axis_label = "10nV"
18178  else:
18179  axis_label = str(LogVStart+V)
18180  print(LNum)
18181  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
18182  J = 2
18183  while J < 10: # Minor Grid lines
18184  ym = y + (Gridpixel*math.log10(J))
18185  Dline = [x1,ym,x2,ym]
18186  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18187  J = J + 1
18188  V = V + 1
18189  else: # Linear Scale
18190  i = 0
18191  Vper = (SAvertmax - SAvertmin) / Vdiv.get()
18192  while (i < Vdiv.get()+1):
18193  y = Y0TF + i * GRHF/Vdiv.get()
18194  Dline = [x1,y,x2,y]
18195  if i == 0 or i == Vdiv.get():
18196  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18197  else:
18198  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18199  axis_value = (SAvertmax - (i * Vper))
18200  axis_label = ' {0:.3f} '.format(axis_value) # str(axis_value)
18201  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
18202  i = i + 1
18203  # Draw vertical grid lines
18204  i = 0
18205  y1 = Y0TF
18206  y2 = Y0TF + GRHF
18207  if HScale.get() == 1:
18208  F = 1.0
18209  LogFStop = math.log10(StopFrequency)
18210  try:
18211  LogFStart = math.log10(StartFrequency)
18212  except:
18213  LogFStart = 0.0
18214  LogFpixel = (LogFStop - LogFStart) / GRWF
18215  # draw left and right edges
18216  while F <= StopFrequency:
18217  if F >= StartFrequency:
18218  try:
18219  LogF = math.log10(F) # convet to log Freq
18220  x = X0LF + (LogF - LogFStart)/LogFpixel
18221  except:
18222  x = X0LF
18223  Dline = [x,y1,x,y2]
18224  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
18225  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18226  axis_label = str(F)
18227  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
18228  else:
18229  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18230 
18231  if F < 10:
18232  F = F + 1
18233  elif F < 100:
18234  F = F + 10
18235  elif F < 1000:
18236  F = F + 100
18237  elif F < 1000:
18238  F = F + 100
18239  elif F < 10000:
18240  F = F + 1000
18241  elif F < 100000:
18242  F = F + 10000
18243  elif F < 200000:
18244  F = F + 10000
18245  else:
18246  Freqdiv = (StopFrequency - StartFrequency) / 10
18247  while (i < 11):
18248  x = X0LF + i * GRWF/10.0
18249  Dline = [x,y1,x,y2]
18250  if i == 0 or i == 10:
18251  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18252  else:
18253  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18254  axis_value = (StartFrequency + (i * Freqdiv))
18255  axis_label = str(axis_value)
18256  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
18257  i = i + 1
18258  # Draw X - Y cursors if needed
18259  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
18260  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
18261  # Vertical conversion factors (level dBs) and border limits
18262  YVconv = float(GRHF) / (SAvertmax - SAvertmin) #
18263  YVc = float(Y0TF) + YVconv * SAvertmax
18264  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
18265  if ShowFCur.get() > 0:
18266  Dline = [FCursor, Y0TF, FCursor, Y0TF+GRHF]
18267  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
18268  # Horizontal conversion factors (frequency Hz) and border limits
18269  if HScale.get() == 1:
18270  LogFStop = math.log10(StopFrequency)
18271  try:
18272  LogFStart = math.log10(StartFrequency)
18273  except:
18274  LogFStart = 0.0
18275  LogFpixel = (LogFStop - LogFStart) / GRWF
18276  xfreq = 10**(((FCursor-X0LF)*LogFpixel) + LogFStart)
18277  else:
18278  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
18279  xfreq = ((FCursor-X0LF)*Fpixel)+StartFrequency
18280  XFString = ' {0:.2f} '.format(xfreq)
18281  V_label = XFString + " Hz"
18282  Freqca.create_text(FCursor+1, Y0TF+GRHF+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
18283  #Freqca.create_text(FCursor+1, dBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
18284 #
18285  if ShowdBCur.get() > 0:
18286  Dline = [X0LF, dBCursor, X0LF+GRWF, dBCursor]
18287  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
18288  if SAVScale.get() == 0: # In dB
18289  yvdB = ((Yc-dBCursor)/Yconv)
18290  VdBString = ' {0:.1f} '.format(yvdB)
18291  V_label = VdBString + " dBV"
18292  elif SAVScale.get() == 1: # Lin Scale
18293  yvdB = ((YVc-dBCursor)/YVconv)
18294  VdBString = ' {0:.3f} '.format(yvdB)
18295  V_label = VdBString + " Vrms"
18296  else: # Log Scale
18297  LogVpixel = (LogVStop - LogVStart) / GRHF
18298  Vlog = ((YVc - dBCursor) * LogVpixel) + LogVStart
18299  yvdB = 10**Vlog
18300  VdBString = ' {:.2e} '.format(yvdB)
18301  V_label = VdBString + " Vrms"
18302 
18303  Freqca.create_text(X0LF+GRWF-5, dBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
18304  #
18305  SmoothBool = SmoothCurvesSA.get()
18306  # Draw traces
18307  if len(T1Fline) > 4: # Avoid writing lines with 1 coordinate
18308  # Write the trace CHA
18309  if OverRangeFlagA == 1:
18310  Freqca.create_line(T1Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18311  else:
18312  Freqca.create_line(T1Fline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18313  if ShowMarker.get() > 0:
18314  k = 1
18315  while k <= HarmonicMarkers.get():
18316  FreqA = k*PeakIndexA*Fsample
18317  #
18318  if SAVScale.get() == 0: # In dB
18319  if SAVPSD.get() == 1:
18320  try:
18321  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])/math.sqrt(FBinWidth))
18322  except:
18323  dbA = -100
18324  else:
18325  try:
18326  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k]))
18327  except:
18328  dbA = -100
18329  if ShowMarker.get() == 2 and k > 1:
18330  Peak_label = ' {0:.2f} '.format(dbA - PeakdbA) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
18331  else:
18332  Peak_label = ' {0:.2f} '.format(dbA) + ',' + ' {0:.1f} '.format(FreqA)
18333  yA = Yc - Yconv * dbA
18334  else: # Volts Scale
18335  try:
18336  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])) # Convert power to DBs
18337  except:
18338  dbA = -100
18339  V = 10.0**(dbA/20.0)# convert back to RMS Volts
18340  PeakV = 10.0**(PeakdbA/20.0)# convert back to RMS Volts
18341  if SAVPSD.get() == 1: # per root Hz
18342  V = V/math.sqrt(FBinWidth)
18343  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
18344  if SAVScale.get() == 2: # Log Scale
18345  LogVpixel = (LogVStop - LogVStart) / GRHF
18346  try:
18347  LogV = math.log10(V) # convet to log Volts
18348  yA = YVc - (LogV - LogVStart)/LogVpixel
18349  except:
18350  yA = YVc - YVconv * V
18351  if ShowMarker.get() == 2 and k > 1:
18352  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
18353  else:
18354  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
18355  else: # Lin Scale
18356  if ShowMarker.get() == 2 and k > 1:
18357  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
18358  else:
18359  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
18360  yA = YVc - YVconv * V
18361  #
18362  if HScale.get() == 1:
18363  try:
18364  LogF = math.log10(FreqA) # convet to log Freq
18365  xA = X0LF + int((LogF - LogFStart)/LogFpixel)
18366  except:
18367  xA = X0LF
18368  else:
18369  xA = X0LF+int((FreqA - StartFrequency)/Fpixel)# +StartFrequency
18370 
18371  Freqca.create_text(xA, yA, text=Peak_label, fill=COLORtrace1, anchor="s", font=("arial", FontSize ))
18372  k = k + 1
18373 
18374  if len(T2Fline) > 4: # Avoid writing lines with 1 coordinate
18375  # Write the trace CHB
18376  if OverRangeFlagB == 1:
18377  Freqca.create_line(T2Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18378  else:
18379  Freqca.create_line(T2Fline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18380  if ShowMarker.get() > 0:
18381  k = 1
18382  while k <= HarmonicMarkers.get():
18383  FreqB = k*PeakIndexB*Fsample
18384  #
18385  if SAVScale.get() == 0: # In dB
18386  if SAVPSD.get() == 1:
18387  try:
18388  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])/math.sqrt(FBinWidth))
18389  except:
18390  dbB = -100
18391  else:
18392  try:
18393  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k]))
18394  except:
18395  dbb = -100
18396  if ShowMarker.get() == 2 and k > 1:
18397  Peak_label = ' {0:.2f} '.format(dbB - PeakdbB) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
18398  else:
18399  Peak_label = ' {0:.2f} '.format(dbB) + ',' + ' {0:.1f} '.format(FreqB)
18400  yB = Yc - Yconv * dbB
18401  else: # Volts Scale
18402  try:
18403  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])) # Convert power to DBs
18404  except:
18405  dbB = -100
18406  V = 10.0**(dbB/20.0)# convert back to RMS Volts
18407  PeakV = 10.0**(PeakdbB/20.0)# convert back to RMS Volts
18408  if SAVPSD.get() == 1: # per root Hz
18409  V = V/math.sqrt(FBinWidth)
18410  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
18411  if SAVScale.get() == 2: # Log Scale
18412  LogVpixel = (LogVStop - LogVStart) / GRHF
18413  try:
18414  LogV = math.log10(V) # convet to log Volts
18415  yB = YVc - (LogV - LogVStart)/LogVpixel
18416  except:
18417  yB = YVc - YVconv * V
18418  if ShowMarker.get() == 2 and k > 1:
18419  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
18420  else:
18421  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
18422  else: # Lin Scale
18423  if ShowMarker.get() == 2 and k > 1:
18424  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
18425  else:
18426  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
18427  yB = YVc - YVconv * V
18428  #
18429  if HScale.get() == 1:
18430  try:
18431  LogF = math.log10(FreqB) # convet to log Freq
18432  xB = X0LF + int((LogF - LogFStart)/LogFpixel)
18433  except:
18434  xB = X0LF
18435  else:
18436  xB = X0LF+int((FreqB - StartFrequency)/Fpixel)# +StartFrequency
18437 
18438  Freqca.create_text(xB, yB, text=Peak_label, fill=COLORtrace2, anchor="s", font=("arial", FontSize ))
18439  k = k + 1
18440 #
18441  if len(T1Pline) > 4: # Avoid writing lines with 1 coordinate
18442  # Write the phase trace A-B
18443  Freqca.create_line(T1Pline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18444  if len(T2Pline) > 4: # Avoid writing lines with 1 coordinate
18445  # Write the phase trace A-B
18446  Freqca.create_line(T2Pline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18447  if ShowAWGASA.get() > 0 and len(TAFline) > 4: # Write the AWG trace A if active
18448  Freqca.create_line(TAFline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18449  if ShowAWGBSA.get() > 0 and len(TBFline) > 4: # Write the AWG trace B if active
18450  Freqca.create_line(TBFline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18451  if ShowRA_VdB.get() == 1 and len(T1FRline) > 4: # Write the ref trace A if active
18452  Freqca.create_line(T1FRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18453  if ShowMarker.get() == 1:
18454  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
18455  Freqca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="s", font=("arial", FontSize ))
18456  if ShowRB_VdB.get() == 1 and len(T2FRline) > 4: # Write the ref trace B if active
18457  Freqca.create_line(T2FRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18458  if ShowMarker.get() == 1:
18459  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
18460  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="s", font=("arial", FontSize ))
18461  if ShowRA_P.get() == 1 and len(T1PRline) > 4: # Write the ref trace A if active
18462  Freqca.create_line(T1PRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18463  if ShowRB_P.get() == 1 and len(T2PRline) > 4: # Write the ref trace A if active
18464  Freqca.create_line(T2PRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18465  if ShowMathSA.get() > 0 and len(TFMline) > 4: # Write the Math trace if active
18466  Freqca.create_line(TFMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18467  if ShowMarker.get() ==1:
18468  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
18469  Freqca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="s", font=("arial", FontSize ))
18470  if ShowRMath.get() == 1 and len(TFRMline) > 4: # Write the ref math trace if active
18471  Freqca.create_line(TFRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18472  if ShowMarker.get() ==1:
18473  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
18474  Freqca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="s", font=("arial", FontSize ))
18475  # General information on top of the grid
18476 
18477  txt = " Sample rate: " + str(SAMPLErate)
18478  txt = txt + " FFT samples: " + str(SMPfft)
18479 
18480  txt = txt + " " + FFTwindowname
18481 
18482  x = X0LF
18483  y = 12
18484  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
18485 
18486  # Start and stop frequency and dB/div and trace mode
18487  txt = str(StartFrequency) + " to " + str(StopFrequency) + " Hz"
18488  txt = txt + " " + str(DBdivlist[DBdivindex.get()]) + " dB/div"
18489  txt = txt + " Level: " + str(DBlevel.get()) + " dB "
18490  if FFTwindow.get() < 7:
18491  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
18492  else:
18493  txt = txt + " FFT Bandwidth = ???"
18494 
18495  x = X0LF
18496  y = Y0TF+GRHF+23
18497  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
18498 
18499  if FreqTraceMode.get() == 1:
18500  txt ="Normal mode "
18501 
18502  if FreqTraceMode.get() == 2:
18503  txt = "Peak hold mode "
18504 
18505  if FreqTraceMode.get() == 3:
18506  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
18507 
18508  if ZEROstuffing.get() > 0:
18509  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
18510  # Runstatus and level information
18511  if (RUNstatus.get() == 0) and (SingleShotSA.get() == 0):
18512  txt = txt + " Stopped "
18513  elif SingleShotSA.get() == 1:
18514  txt = txt + " Single Shot Trace "
18515  else:
18516  if FreqDisp.get() == 1:
18517  txt = txt + " Running "
18518  else:
18519  txt = txt + " Display off "
18520  x = X0LF
18521  y = Y0TF+GRHF+34
18522  IDtxt = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
18523 
18524 def INITIALIZEstart():
18525  global SMPfft, FFTwindow
18526  global SMPfftpwrTwo, BodeDisp
18527  global TRACEresetFreq, FreqTraceMode, LoopNum, FSweepMode, FSweepCont
18528 
18529  # First some subroutines to set specific variables
18530  if BodeDisp.get() == 0:
18531  if FFTwindow.get() != 8:
18532  SMPfft = 2 ** int(SMPfftpwrTwo.get()) # Calculate the number of FFT samples from SMPfftpwrtwo
18533 
18535  if FreqTraceMode.get() == 1 and TRACEresetFreq == False:
18536  TRACEresetFreq = True # Clear the memory for averaging or peak
18537  if FreqTraceMode.get() == 2 and LoopNum.get() == 1 and FSweepMode.get() > 0 and FSweepCont.get() == 0 and BodeDisp.get() >0:
18538  TRACEresetFreq = True # Clear the memory for peak hold when using sweep generator
18539 
18540 def CALCFFTwindowshape(): # Make the FFTwindowshape for the windowing function
18541  global FFTbandwidth # The FFT bandwidth
18542  global FFTwindow # Which FFT window number is selected
18543  global FFTwindowname # The name of the FFT window function
18544  global FFTwindowshape # The window shape
18545  global AWGSAMPLErate, SAMPLErate, BaseSampleRate # The sample rate
18546  global SMPfft # Number of FFT samples
18547  global LastWindow, LastSMPfft
18548 
18549  if LastWindow == FFTwindow.get() and LastSMPfft == SMPfft:
18550  # recalculate window only if something changed
18551  return
18552  # FFTname and FFTbandwidth in milliHz
18553  FFTwindowname = "No such window"
18554  FFTbw = 0
18555 
18556  if FFTwindow.get() == 0:
18557  FFTwindowname = " Rectangular (no) window (B=1) "
18558  FFTbw = 1.0
18559 
18560  if FFTwindow.get() == 1:
18561  FFTwindowname = " Cosine window (B=1.24) "
18562  FFTbw = 1.24
18563 
18564  if FFTwindow.get() == 2:
18565  FFTwindowname = " Triangular window (B=1.33) "
18566  FFTbw = 1.33
18567 
18568  if FFTwindow.get() == 3:
18569  FFTwindowname = " Hann window (B=1.5) "
18570  FFTbw = 1.5
18571 
18572  if FFTwindow.get() == 4:
18573  FFTwindowname = " Blackman window (B=1.73) "
18574  FFTbw = 1.73
18575 
18576  if FFTwindow.get() == 5:
18577  FFTwindowname = " Nuttall window (B=2.02) "
18578  FFTbw = 2.02
18579 
18580  if FFTwindow.get() == 6:
18581  FFTwindowname = " Flat top window (B=3.77) "
18582  FFTbw = 3.77
18583 
18584  if FFTwindow.get() == 7:
18585  FFTwindowname = FFTUserWindowString
18586  FFTbw = 0.0
18587  try:
18588  FFTwindowshape = eval(FFTUserWindowString)
18589  except:
18590  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
18591  print( "Filling FFT window with Ones")
18592  elif FFTwindow.get() == 8: # window shape array read from csv file
18593  FFTwindowname = "Window Shape From file"
18594  FFTbw = 0.0
18595  else:
18596  FFTbandwidth = int(FFTbw * (SAMPLErate/2.0) / float(SMPfft))
18597  # Calculate the shape
18598  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
18599  n = 0
18600  while n < SMPfft:
18601  # Cosine window function - medium-dynamic range B=1.24
18602  if FFTwindow.get() == 1:
18603  w = math.sin(math.pi * n / (SMPfft - 1))
18604  FFTwindowshape[n] = w * 1.571
18605  # Triangular non-zero endpoints - medium-dynamic range B=1.33
18606  if FFTwindow.get() == 2:
18607  w = (2.0 / SMPfft) * ((SMPfft/ 2.0) - abs(n - (SMPfft - 1) / 2.0))
18608  FFTwindowshape[n] = w * 2.0
18609  # Hann window function - medium-dynamic range B=1.5
18610  if FFTwindow.get() == 3:
18611  w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1))
18612  FFTwindowshape[n] = w * 2.000
18613  # Blackman window, continuous first derivate function - medium-dynamic range B=1.73
18614  if FFTwindow.get() == 4:
18615  w = 0.42 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.08 * math.cos(4 * math.pi * n / (SMPfft - 1))
18616  FFTwindowshape[n] = w * 2.381
18617  # Nuttall window, continuous first derivate function - high-dynamic range B=2.02
18618  if FFTwindow.get() == 5:
18619  w = 0.355768 - 0.487396 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.144232 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.012604 * math.cos(6 * math.pi * n / (SMPfft - 1))
18620  FFTwindowshape[n] = w * 2.811
18621  # Flat top window, medium-dynamic range, extra wide bandwidth B=3.77
18622  if FFTwindow.get() == 6:
18623  w = 1.0 - 1.93 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 1.29 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.388 * math.cos(6 * math.pi * n / (SMPfft - 1)) + 0.032 * math.cos(8 * math.pi * n / (SMPfft - 1))
18624  FFTwindowshape[n] = w * 1.000
18625  n = n + 1
18626  LastWindow = FFTwindow.get()
18627  LastSMPfft = SMPfft
18628 
18629 def BUserFFTwindow():
18630  global FFTUserWindowString, freqwindow, bodewindow, SpectrumScreenStatus, BodeScreenStatus
18631 
18632  TempString = FFTUserWindowString
18633  if BodeScreenStatus.get() > 0:
18634  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=bodewindow)
18635  elif SpectrumScreenStatus.get() > 0:
18636  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=freqwindow)
18637  else:
18638  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString)
18639  if (FFTUserWindowString == None): # If Cancel pressed, then None
18640  FFTUserWindowString = TempString
18641 
18642 def BFileFFTwindow():
18643  global FFTwindowshape, SMPfft, LastSMPfft, FFTwindow, LastWindow
18644 
18645  # Read values from CVS file
18646  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=freqwindow)
18647  try:
18648  CSVFile = open(filename)
18649  csv_f = csv.reader(CSVFile)
18650  FFTwindowshape = []
18651  for row in csv_f:
18652  try:
18653  FFTwindowshape.append(float(row[0]))
18654  except:
18655  print( 'skipping non-numeric row')
18656  FFTwindowshape = numpy.array(FFTwindowshape)
18657  CSVFile.close()
18658  SMPfft = len(FFTwindowshape)
18659  LastSMPfft = SMPfft
18660  LastWindow = FFTwindow.get()
18661  print( SMPfft)
18662  except:
18663  showwarning("WARNING","No such file found or wrong format!")
18664 #
18665 def onCanvasFreqRightClick(event):
18666  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
18667 
18668  FCursor = event.x
18669  dBCursor = event.y
18670  if RUNstatus.get() == 0:
18672  Freqca.bind('<MouseWheel>', onCanvasFreqClickScroll)
18673  Freqca.bind("<Button-4>", onCanvasFreqClickScroll)# with Linux OS
18674  Freqca.bind("<Button-5>", onCanvasFreqClickScroll)
18675 #
18676 def onCanvasFreqClickScroll(event):
18677  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
18678 
18679  if event.widget == Freqca:
18680  ShiftKeyDwn = event.state & 1
18681  if ShowFCur.get() > 0 and ShiftKeyDwn == 0:
18682  # respond to Linux or Windows wheel event
18683  if event.num == 5 or event.delta == -120:
18684  FCursor -= 1
18685  if event.num == 4 or event.delta == 120:
18686  FCursor += 1
18687  elif ShowdBCur.get() > 0 or ShiftKeyDwn == 1:
18688  # respond to Linux or Windows wheel event
18689  if event.num == 5 or event.delta == -120:
18690  dBCursor += 1
18691  if event.num == 4 or event.delta == 120:
18692  dBCursor -= 1
18693  if RUNstatus.get() == 0:
18695 #
18696 def onCanvasFreqLeftClick(event):
18697  global X0LF # Left top X value
18698  global Y0TF # Left top Y value
18699  global GRWF # Screenwidth
18700  global GRHF # Screenheight
18701  global FontSize
18702  global Freqca, MarkerLoc, SAMPLErate, BaseSampleRate
18703  global COLORgrid, COLORtext, HScale, ShowC1_VdB, ShowC2_VdB
18704  global COLORtrace1, COLORtrace2, StartFreqEntry, StopFreqEntry
18705  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF
18706  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
18707 
18708  if (RUNstatus.get() == 0):
18709  MarkerFreqNum = MarkerFreqNum + 1
18710  COLORmarker = COLORgrid
18711  if ShowC1_VdB.get() == 1:
18712  COLORmarker = COLORtrace1
18713  elif ShowC2_VdB.get() == 1:
18714  COLORmarker = COLORtrace2
18715  try:
18716  StartFrequency = float(StartFreqEntry.get())
18717  except:
18718  StartFreqEntry.delete(0,"end")
18719  StartFreqEntry.insert(0,100)
18720  StartFrequency = 100
18721  try:
18722  StopFrequency = float(StopFreqEntry.get())
18723  except:
18724  StopFreqEntry.delete(0,"end")
18725  StopFreqEntry.insert(0,100)
18726  StopFrequency = 100
18727  # draw X at marker point and number
18728  Freqca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
18729  Freqca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
18730  Freqca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
18731  # Vertical conversion factors (level dBs) and border limits
18732  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
18733  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
18734  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
18735  YVc = float(Y0TF) + YVconv * SAvertmax
18736  Yphconv = float(GRHF) / 360
18737  Yp = float(Y0TF) + Yphconv + 180
18738  # Horizontal conversion factors (frequency Hz) and border limits
18739  if HScale.get() == 1:
18740  LogFStop = math.log10(StopFrequency)
18741  try:
18742  LogFStart = math.log10(StartFrequency)
18743  except:
18744  LogFStart = 0.0
18745  LogFpixel = (LogFStop - LogFStart) / GRWF
18746  xfreq = 10**(((event.x-X0LF)*LogFpixel) + LogFStart)
18747  else:
18748  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
18749  xfreq = ((event.x-X0LF)*Fpixel)+StartFrequency
18750  #
18751  try:
18752  LogVStop = math.log10(SAvertmax)
18753  except:
18754  LogVStop = 0.0
18755  try:
18756  LogVStart = math.log10(SAvertmin)
18757  except:
18758  LogVStart = -10
18759  LogVpixel = (LogVStop - LogVStart) / GRHF
18760  #
18761  XFString = ' {0:.2f} '.format(xfreq)
18762  if SAVScale.get() == 0:
18763  yvdB = ((Yc-event.y)/Yconv)
18764  VdBString = ' {0:.3f} '.format(yvdB)
18765  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
18766  else:
18767  if SAVScale.get() == 1:
18768  yvdB = ((YVc-event.y)/YVconv)
18769  VdBString = ' {0:.3f} '.format(yvdB)
18770  else:
18771  Vlog = ((YVc - event.y) * LogVpixel) + LogVStart
18772  yvdB = 10**Vlog
18773  VdBString = ' {:.2e} '.format(yvdB)
18774  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " Vrms"
18775 
18776  if MarkerFreqNum > 1:
18777  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18778  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
18779  if SAVScale.get() == 0:
18780  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18781  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
18782  else:
18783  if SAVScale.get() == 1:
18784  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18785  else:
18786  DeltaV = ' {0:.2e} '.format(yvdB-PrevdBV)
18787  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " Vrms"
18788  x = X0LF + 5
18789  y = Y0TF + 3 + (MarkerFreqNum*10)
18790  Justify = 'w'
18791  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
18792  x = X0LF + GRWF - 5
18793  y = Y0TF + 3 + (MarkerFreqNum*10)
18794  Justify = 'e'
18795  if MarkerLoc == 'LL' or MarkerLoc == 'll':
18796  x = X0LF + 5
18797  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
18798  Justify = 'w'
18799  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
18800  x = X0LF + GRWF - 5
18801  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
18802  Justify = 'e'
18803  Freqca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
18804  PrevdBV = yvdB
18805  PrevF = xfreq
18806 #
18807 def onCanvasSAOne(event):
18808  global ShowC1_VdB
18809  if ShowC1_VdB.get() == 0:
18810  ShowC1_VdB.set(1)
18811  else:
18812  ShowC1_VdB.set(0)
18813 #
18814 def onCanvasSATwo(event):
18815  global ShowC2_VdB
18816  if ShowC2_VdB.get() == 0:
18817  ShowC2_VdB.set(1)
18818  else:
18819  ShowC2_VdB.set(0)
18820 #
18821 def onCanvasSAThree(event):
18822  global ShowC1_P
18823  if ShowC1_P.get() == 0:
18824  ShowC1_P.set(1)
18825  else:
18826  ShowC1_P.set(0)
18827 #
18828 def onCanvasSAFour(event):
18829  global ShowC2_P
18830  if ShowC2_P.get() == 0:
18831  ShowC2_P.set(1)
18832  else:
18833  ShowC2_P.set(0)
18834 #
18835 def onCanvasSAFive(event):
18836  global ShowMarker
18837  if ShowMarker.get() == 0:
18838  ShowMarker.set(1)
18839  else:
18840  ShowMarker.set(0)
18841 #
18842 def onCanvasSASix(event):
18843  global ShowRA_VdB
18844  if ShowRA_VdB.get() == 0:
18845  ShowRA_VdB.set(1)
18846  else:
18847  ShowRA_VdB.set(0)
18848 #
18849 def onCanvasSASeven(event):
18850  global ShowRB_VdB
18851  if ShowRB_VdB.get() == 0:
18852  ShowRB_VdB.set(1)
18853  else:
18854  ShowRB_VdB.set(0)
18855 #
18856 def onCanvasSAEight(event):
18857  global ShowMathSA
18858  ShowMathSA.set(2)
18859 #
18860 def onCanvasSANine(event):
18861  global ShowMathSA
18862  ShowMathSA.set(1)
18863 #
18864 def onCanvasSAZero(event):
18865  global ShowMathSA
18866  ShowMathSA.set(0)
18867 #
18868 def onCanvasSASnap(event):
18869  BSTOREtraceSA()
18870 #
18871 def onCanvasSANormal(event):
18872  BNormalmode()
18873 #
18874 def onCanvasSAPeak(event):
18875  BPeakholdmode()
18876 
18877 def onCanvasSAReset(event):
18878  BResetFreqAvg()
18879 #
18880 def onCanvasSAAverage(event):
18881  BAveragemode()
18882 #
18883 def onCanvasShowFcur(event):
18884  global ShowFCur
18885  if ShowFCur.get() == 0:
18886  ShowFCur.set(1)
18887  else:
18888  ShowFCur.set(0)
18889 #
18890 def onCanvasShowdBcur(event):
18891  global ShowdBCur
18892  if ShowdBCur.get() == 1:
18893  ShowdBCur.set(0)
18894  else:
18895  ShowdBCur.set(1)
18896 #
18897 def onCanvasShowPcur(event):
18898  global ShowdBCur
18899  if ShowdBCur.get() == 2:
18900  ShowdBCur.set(0)
18901  else:
18902  ShowdBCur.set(2)
18903 #
18904 def onCanvasBodeRightClick(event):
18905  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus, Bodeca
18906 
18907  BPCursor = event.x
18908  BdBCursor = event.y
18909  if RUNstatus.get() == 0:
18911  #Bodeca.bind_all('<MouseWheel>', onCanvasBodeClickScroll)
18912  Bodeca.bind('<MouseWheel>', onCanvasBodeClickScroll)
18913  Bodeca.bind("<Button-4>", onCanvasBodeClickScroll)# with Linux OS
18914  Bodeca.bind("<Button-5>", onCanvasBodeClickScroll)
18915 #
18916 def onCanvasBodeClickScroll(event):
18917  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus
18918 
18919  # print event.state
18920  shift_key = event.state & 1
18921  if ShowBPCur.get() > 0 and shift_key == 0:
18922  # respond to Linux or Windows wheel event
18923  if event.num == 5 or event.delta == -120:
18924  BPCursor -= 1
18925  if event.num == 4 or event.delta == 120:
18926  BPCursor += 1
18927  elif ShowBdBCur.get() > 0 or shift_key == 1:
18928  # respond to Linux or Windows wheel event
18929  if event.num == 5 or event.delta == -120:
18930  BdBCursor += 1
18931  if event.num == 4 or event.delta == 120:
18932  BdBCursor -= 1
18933  if RUNstatus.get() == 0:
18935 #
18936 def onCanvasBodeLeftClick(event):
18937  global X0LBP # Left top X value
18938  global Y0TBP # Left top Y value
18939  global GRWBP # Screenwidth
18940  global GRHBP # Screenheight
18941  global FontSize
18942  global Bodeca, MarkerLoc, SAMPLErate
18943  global COLORgrid, COLORtext, HScaleBP, ShowCA_VdB, ShowCB_VdB, DBdivindexBP
18944  global COLORtrace1, COLORtrace2, COLORtrace6, StartBodeEntry, StopBodeEntry, DBlevelBP
18945  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF, Vdiv
18946 
18947  if (RUNstatus.get() == 0):
18948  MarkerFreqNum = MarkerFreqNum + 1
18949  COLORmarker = COLORtrace6 # COLORgrid
18950  if ShowCA_VdB.get() == 1:
18951  COLORmarker = COLORtrace1
18952  elif ShowCB_VdB.get() == 1:
18953  COLORmarker = COLORtrace2
18954  try:
18955  EndFreq = float(StopBodeEntry.get())
18956  except:
18957  StopBodeEntry.delete(0,"end")
18958  StopBodeEntry.insert(0,10000)
18959  EndFreq = 10000
18960  try:
18961  BeginFreq = float(StartBodeEntry.get())
18962  except:
18963  StartBodeEntry.delete(0,"end")
18964  StartBodeEntry.insert(0,100)
18965  BeginFreq = 100
18966  # draw X at marker point and number
18967  Bodeca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
18968  Bodeca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
18969  Bodeca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
18970  # Vertical conversion factors (level dBs) and border limits
18971  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
18972  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
18973  Yphconv = float(GRHBP) / 360
18974  Yp = float(Y0TBP) + Yphconv + 180
18975  x1 = X0LBP + 14
18976  x2 = x1 + GRWBP
18977  # Horizontal conversion factors (frequency Hz) and border limits
18978  if HScaleBP.get() == 1:
18979  LogFStop = math.log10(EndFreq)
18980  try:
18981  LogFStart = math.log10(BeginFreq)
18982  except:
18983  LogFStart = 0.0
18984  LogFpixel = (LogFStop - LogFStart) / GRWBP
18985  xfreq = 10**(((event.x-x1)*LogFpixel) + LogFStart)
18986  else:
18987  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
18988  xfreq = ((event.x-x1)*Fpixel)+BeginFreq
18989 
18990  yvdB = ((Yc-event.y)/Yconv)
18991  VdBString = ' {0:.1f} '.format(yvdB)
18992  XFString = ' {0:.2f} '.format(xfreq)
18993  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
18994  if MarkerFreqNum > 1:
18995  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18996  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
18997  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
18998  x = x1 + 5
18999  y = Y0TBP + 3 + (MarkerFreqNum*10)
19000  Justify = 'w'
19001  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
19002  x = x2 - 5
19003  y = Y0TBP + 3 + (MarkerFreqNum*10)
19004  Justify = 'e'
19005  if MarkerLoc == 'LL' or MarkerLoc == 'll':
19006  x = x1 + 5
19007  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
19008  Justify = 'w'
19009  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
19010  x = x2 - 5
19011  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
19012  Justify = 'e'
19013  Bodeca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
19014  PrevdBV = yvdB
19015  PrevF = xfreq
19016 #
19017 def onCanvasBdOne(event):
19018  global ShowCA_VdB
19019  if ShowCA_VdB.get() == 0:
19020  ShowCA_VdB.set(1)
19021  else:
19022  ShowCA_VdB.set(0)
19023 #
19024 def onCanvasBdTwo(event):
19025  global ShowCB_VdB
19026  if ShowCB_VdB.get() == 0:
19027  ShowCB_VdB.set(1)
19028  else:
19029  ShowCB_VdB.set(0)
19030 #
19031 def onCanvasBdThree(event):
19032  global ShowCA_P
19033  if ShowCA_P.get() == 0:
19034  ShowCA_P.set(1)
19035  else:
19036  ShowCA_P.set(0)
19037 #
19038 def onCanvasBdFour(event):
19039  global ShowCB_P
19040  if ShowCB_P.get() == 0:
19041  ShowCB_P.set(1)
19042  else:
19043  ShowCB_P.set(0)
19044 #
19045 def onCanvasBdFive(event):
19046  global ShowMarkerBP
19047  if ShowMarkerBP.get() == 0:
19048  ShowMarkerBP.set(1)
19049  else:
19050  ShowMarkerBP.set(0)
19051 #
19052 def onCanvasBdSix(event):
19053  global ShowRA_VdB
19054  if ShowRA_VdB.get() == 0:
19055  ShowRA_VdB.set(1)
19056  else:
19057  ShowRA_VdB.set(0)
19058 #
19059 def onCanvasBdSeven(event):
19060  global ShowRB_VdB
19061  if ShowRB_VdB.get() == 0:
19062  ShowRB_VdB.set(1)
19063  else:
19064  ShowRB_VdB.set(0)
19065 #
19066 def onCanvasBdEight(event):
19067  global ShowMathBP
19068  ShowMathBP.set(2)
19069 #
19070 def onCanvasBdNine(event):
19071  global ShowMathBP
19072  ShowMathBP.set(1)
19073 #
19074 def onCanvasBdZero(event):
19075  global ShowMathBP
19076  ShowMathBP.set(0)
19077 #
19078 def onCanvasBdSnap(event):
19079  BSTOREtraceBP()
19080 #
19081 def onCanvasShowBPcur(event):
19082  global ShowBPCur
19083  if ShowBPCur.get() == 0:
19084  ShowBPCur.set(1)
19085  else:
19086  ShowBPCur.set(0)
19087 #
19088 def onCanvasShowBdBcur(event):
19089  global ShowBdBCur
19090  if ShowBdBCur.get() == 1:
19091  ShowBdBCur.set(0)
19092  else:
19093  ShowBdBCur.set(1)
19094 #
19095 def onCanvasShowPdBcur(event):
19096  global ShowBdBCur
19097  if ShowBdBCur.get() == 2:
19098  ShowBdBCur.set(0)
19099  else:
19100  ShowBdBCur.set(2)
19101 #
19102 def onAWGAscroll(event):
19103  global AWGAShape
19104 
19105  onTextScroll(event)
19106  time.sleep(0.05)
19107  ReMakeAWGwaves()
19108  time.sleep(0.05)
19109 #
19110 def onAWGBscroll(event):
19111  global AWGBShape
19112 
19113  onTextScroll(event)
19114  time.sleep(0.05)
19115  ReMakeAWGwaves()
19116  time.sleep(0.05)
19117 #
19118 def onTextScroll(event): # Use mouse wheel to scroll entry values, august 7
19119  button = event.widget
19120  cursor_position = button.index(INSERT) # get current cursor position
19121  Pos = cursor_position
19122  OldVal = button.get() # get current entry string
19123  OldValfl = float(OldVal) # and its value
19124  NewVal = OldValfl
19125  Len = len(OldVal)
19126  Dot = OldVal.find (".") # find decimal point position
19127  Decimals = Len - Dot - 1
19128  if Dot == -1 : # no point
19129  Decimals = 0
19130  Step = 10**(Len - Pos)
19131  elif Pos <= Dot : # no point left of position
19132  Step = 10**(Dot - Pos)
19133  else:
19134  Step = 10**(Dot - Pos + 1)
19135  # respond to Linux or Windows wheel event
19136  if event.num == 5 or event.delta == -120:
19137  NewVal = OldValfl - Step
19138  if event.num == 4 or event.delta == 120:
19139  NewVal = OldValfl + Step
19140  FormatStr = "{0:." + str(Decimals) + "f}"
19141  NewStr = FormatStr.format(NewVal)
19142  NewDot = NewStr.find (".")
19143  NewPos = Pos + NewDot - Dot
19144  if Decimals == 0 :
19145  NewLen = len(NewStr)
19146  NewPos = Pos + NewLen - Len
19147  button.delete(0, END) # remove old entry
19148  button.insert(0, NewStr) # insert new entry
19149  button.icursor(NewPos) # resets the insertion cursor
19150 #
19151 def onAWGAkey(event):
19152  global AWGAShape
19153 
19154  onTextKey(event)
19155  ReMakeAWGwaves()
19156 #
19157 def onAWGBkey(event):
19158  global AWGBShape
19159 
19160  onTextKey(event)
19161  ReMakeAWGwaves()
19162 #
19163 def onTextKeyAWG(event):
19164  onTextKey(event)
19165  ReMakeAWGwaves()
19166 #
19167 # Use Arriw keys to inc dec entry values
19168 def onTextKey(event):
19169  button = event.widget
19170  cursor_position = button.index(INSERT) # get current cursor position
19171  Pos = cursor_position
19172  OldVal = button.get() # get current entry string
19173  OldValfl = float(OldVal) # and its value
19174  Len = len(OldVal)
19175  Dot = OldVal.find (".") # find decimal point position
19176  Decimals = Len - Dot - 1
19177  if Dot == -1 : # no point
19178  Decimals = 0
19179  Step = 10**(Len - Pos)
19180  elif Pos <= Dot : # no point left of position
19181  Step = 10**(Dot - Pos)
19182  else:
19183  Step = 10**(Dot - Pos + 1)
19184  if platform.system() == "Windows":
19185  if event.keycode == 38: # increment digit for up arrow key
19186  NewVal = OldValfl + Step
19187  elif event.keycode == 40: # decrement digit for down arrow
19188  NewVal = OldValfl - Step
19189  else:
19190  return
19191  elif platform.system() == "Linux":
19192  if event.keycode == 111: # increment digit for up arrow key
19193  NewVal = OldValfl + Step
19194  elif event.keycode == 116: # decrement digit for down arrow
19195  NewVal = OldValfl - Step
19196  else:
19197  return
19198  elif platform.system() == "Darwin":
19199  if event.keycode == 0x7D: # increment digit for up arrow key
19200  NewVal = OldValfl + Step
19201  elif event.keycode == 0x7E: # decrement digit for down arrow
19202  NewVal = OldValfl - Step
19203  else:
19204  return
19205  else:
19206  return
19207 #
19208  FormatStr = "{0:." + str(Decimals) + "f}"
19209  NewStr = FormatStr.format(NewVal)
19210  NewDot = NewStr.find (".")
19211  NewPos = Pos + NewDot - Dot
19212  if Decimals == 0 :
19213  NewLen = len(NewStr)
19214  NewPos = Pos + NewLen - Len
19215  button.delete(0, END) # remove old entry
19216  button.insert(0, NewStr) # insert new entry
19217  button.icursor(NewPos) # resets the insertion cursor
19218 #
19219 #
19220 def onSpinBoxScroll(event):
19221  spbox = event.widget
19222  if sys.version_info[0] == 3 and sys.version_info[1] > 6: # Spin Boxes do this automatically in Python > 3.6 apparently
19223  return
19224  if event.num == 4 or event.delta > 0: # if event.delta > 0: # increment digit
19225  spbox.invoke('buttonup')
19226  if event.num == 5 or event.delta < 0:
19227  spbox.invoke('buttondown')
19228 #
19229 # ================ Make awg sub window ==========================
19230 def MakeAWGWindow():
19231  global AWGAMode, AWGATerm, AWGAShape, AWGSync, awgwindow, AWGAPhaseDelay, AWGBPhaseDelay
19232  global AWGBMode, AWGBTerm, AWGBShape, AWGScreenStatus, AWGARepeatFlag, AWGBRepeatFlag
19233  global AWGABurstFlag, AWGBBurstFlag, AWGAShapeLabel, AWGBShapeLabel, AWGShowAdvanced
19234  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGAPhaseEntry, AWGADutyCycleEntry
19235  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBPhaseEntry, AWGBDutyCycleEntry
19236  global AWGALength, AWGBLength, RevDate, phasealab, phaseblab, AWGAModeLabel, AWGBModeLabel
19237  global AWGAIOMode, AWGBIOMode, duty1lab, duty2lab, awgaph, awgadel, awgbph, awgbdel
19238  global AwgLayout, AWG_Amp_Mode, awgsync, SWRev # 0 = Min/Max mode, 1 = Amp/Offset
19239  global amp1lab, amp2lab, off1lab, off2lab, Reset_Freq, AWG_2X, BisCompA, FWRevOne
19240  global ModeAMenu, ShapeAMenu, amp1lab, off1lab, freq1lab, awgaph, awgadel, ModeBMenu, ShapeBMenu
19241  global amp2lab, off2lab, freq2lab, awgbph, awgbdel, bcompa, awgsync, LockFreq
19242  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise, NoiseList
19243 
19244  if AWGScreenStatus.get() == 0:
19245  AWGScreenStatus.set(1)
19246 
19247  awgwindow = Toplevel()
19248  awgwindow.title("AWG Controls " + SWRev + RevDate)
19249  awgwindow.resizable(FALSE,FALSE)
19250  awgwindow.geometry('+0+100')
19251  awgwindow.protocol("WM_DELETE_WINDOW", DestroyAWGScreen)
19252  #
19253  frame2 = LabelFrame(awgwindow, text="AWG CH A", style="A10R1.TLabelframe")
19254  frame3 = LabelFrame(awgwindow, text="AWG CH B", style="A10R2.TLabelframe")
19255  #
19256  if AwgLayout == "Horz":
19257  frame2.pack(side=LEFT, expand=1, fill=X)
19258  frame3.pack(side=LEFT, expand=1, fill=X)
19259  else:
19260  frame2.pack(side=TOP, expand=1, fill=Y)
19261  frame3.pack(side=TOP, expand=1, fill=Y)
19262  # now AWG A
19263  # AWG enable sub frame
19264  awg1eb = Frame( frame2 )
19265  awg1eb.pack(side=TOP)
19266  ModeAMenu = Menubutton(awg1eb, text="Mode", style="W5.TButton")
19267  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
19268  ModeAMenu["menu"] = ModeAMenu.menu
19269  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
19270  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
19271  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
19272  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
19273  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
19274  ModeAMenu.menu.add_separator()
19275  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
19276  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
19277  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
19278  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
19279  ModeAMenu.pack(side=LEFT, anchor=W)
19280  ShapeAMenu = Menubutton(awg1eb, text="Shape", style="W6.TButton")
19281  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
19282  ShapeAMenu["menu"] = ShapeAMenu.menu
19283  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
19284  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
19285  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
19286  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
19287  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
19288  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
19289  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
19290  if AWGShowAdvanced.get() > 0:
19291  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
19292  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
19293  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
19294  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
19295  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
19296  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
19297  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
19298  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
19299  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
19300  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
19301  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
19302  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
19303  ShapeAMenu.menu.add_radiobutton(label="Full Wave", variable=AWGAShape, value=23, command=ReMakeAWGwaves)
19304  ShapeAMenu.menu.add_radiobutton(label="Half Wave", variable=AWGAShape, value=24, command=ReMakeAWGwaves)
19305  # These stand alone shapes are now redundant, use add noise to 0 amplt sine
19306  # ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
19307  # ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
19308  else:
19309  ShapeAMenu.menu.add_separator()
19310  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
19311  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
19312  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
19313  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
19314  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
19315  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
19316  ShapeAMenu.pack(side=LEFT, anchor=W)
19317  #
19318  AWGAModeLabel = Label(frame2, text="AWG A Mode")
19319  AWGAModeLabel.pack(side=TOP)
19320  AWGAShapeLabel = Label(frame2, text="AWG A Shape")
19321  AWGAShapeLabel.pack(side=TOP)
19322  #
19323  awg1ampl = Frame( frame2 )
19324  awg1ampl.pack(side=TOP)
19325  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
19326  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
19327  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
19328  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19329  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
19330  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
19331  AWGAAmplEntry.pack(side=LEFT, anchor=W)
19332  AWGAAmplEntry.delete(0,"end")
19333  AWGAAmplEntry.insert(0,0.0)
19334  amp1lab = Label(awg1ampl) #, text="Min Ch A")
19335  amp1lab.pack(side=LEFT, anchor=W)
19336  #
19337  awg1off = Frame( frame2 )
19338  awg1off.pack(side=TOP)
19339  AWGAOffsetEntry = Entry(awg1off, width=5, cursor='double_arrow')
19340  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
19341  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
19342  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19343  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
19344  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
19345  AWGAOffsetEntry.pack(side=LEFT, anchor=W)
19346  AWGAOffsetEntry.delete(0,"end")
19347  AWGAOffsetEntry.insert(0,0.0)
19348  off1lab = Label(awg1off) #, text="Max Ch A")
19349  off1lab.pack(side=LEFT, anchor=W)
19350  if AWG_Amp_Mode.get() == 0:
19351  amp1lab.config(text = "Min Ch A" ) # change displayed value
19352  off1lab.config(text = "Max Ch A" ) # change displayed value
19353  else:
19354  amp1lab.config(text = "Amp Ch A" )
19355  off1lab.config(text = "Off Ch A" )
19356  # AWG Frequency sub frame
19357  awg1freq = Frame( frame2 )
19358  awg1freq.pack(side=TOP)
19359  AWGAFreqEntry = Entry(awg1freq, width=7, cursor='double_arrow')
19360  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
19361  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
19362  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19363  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
19364  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
19365  AWGAFreqEntry.pack(side=LEFT, anchor=W)
19366  AWGAFreqEntry.delete(0,"end")
19367  AWGAFreqEntry.insert(0,100.0)
19368  freq1lab = Label(awg1freq, text="Freq Ch A")
19369  freq1lab.pack(side=LEFT, anchor=W)
19370  # AWG Phase or delay select sub frame
19371  # AWG Phase entry sub frame
19372  awg1phase = Frame( frame2 )
19373  awg1phase.pack(side=TOP)
19374  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
19375  awgaph.pack(side=LEFT, anchor=W)
19376  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
19377  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
19378  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
19379  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19380  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
19381  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
19382  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
19383  AWGAPhaseEntry.delete(0,"end")
19384  AWGAPhaseEntry.insert(0,0)
19385  phasealab = Label(awg1phase, text="Deg")
19386  phasealab.pack(side=LEFT, anchor=W)
19387  # AWG duty cycle frame
19388  awg1dc = Frame( frame2 )
19389  awg1dc.pack(side=TOP)
19390  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
19391  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
19392  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
19393  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19394  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
19395  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
19396  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
19397  AWGADutyCycleEntry.delete(0,"end")
19398  AWGADutyCycleEntry.insert(0,50)
19399  duty1lab = Label(awg1dc, text="%")
19400  duty1lab.pack(side=LEFT, anchor=W)
19401  #
19402  AWGALength = Label(frame2, text="Length")
19403  AWGALength.pack(side=TOP)
19404  # Noise Controls
19405  anoise = Frame( frame2 )
19406  anoise.pack(side=TOP)
19407  AWGANoise = Label(anoise, text="Noise")
19408  AWGANoise.pack(side=LEFT, anchor=W)
19409  AWGAsbnoise = Spinbox(anoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
19410  AWGAsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
19411  AWGAsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19412  AWGAsbnoise.bind("<Button-5>", onSpinBoxScroll)
19413  AWGAsbnoise.pack(side=LEFT, anchor=W)
19414  AWGANoiseEntry = Entry(anoise, width=5, cursor='double_arrow')
19415  AWGANoiseEntry.bind("<Return>", UpdateAwgContRet)
19416  AWGANoiseEntry.bind('<MouseWheel>', onAWGAscroll)
19417  AWGANoiseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19418  AWGANoiseEntry.bind("<Button-5>", onAWGAscroll)
19419  AWGANoiseEntry.bind('<Key>', onTextKeyAWG)
19420  AWGANoiseEntry.pack(side=LEFT, anchor=W)
19421  AWGANoiseEntry.delete(0,"end")
19422  AWGANoiseEntry.insert(0,0.0)
19423  #
19424  freqlock = Checkbutton(frame2, text="Lock Freq", variable=LockFreq) # , command=)
19425  freqlock.pack(side=TOP)
19426  if FWRevOne > 2.16:
19427  awg2x1 = Radiobutton(frame2, text="Both CH 1X", variable=AWG_2X, value=0, command=BAWG2X)
19428  awg2x1.pack(side=TOP)
19429  axg2xf = Frame( frame2 )
19430  axg2xf.pack(side=TOP)
19431  awg2x2 = Radiobutton(axg2xf, text="CH A 2X", variable=AWG_2X, value=1, command=BAWG2X)
19432  awg2x2.pack(side=LEFT, anchor=W)
19433  awg2x3 = Radiobutton(axg2xf, text="CH B 2X", variable=AWG_2X, value=2, command=BAWG2X)
19434  awg2x3.pack(side=LEFT, anchor=W)
19435  else:
19436  awgsync = Checkbutton(frame2, text="Sync AWG", variable=AWGSync, command=BAWGSync)
19437  awgsync.pack(side=TOP)
19438  # now AWG B
19439  # AWG enable sub frame
19440  awg2eb = Frame( frame3 )
19441  awg2eb.pack(side=TOP)
19442  ModeBMenu = Menubutton(awg2eb, text="Mode", style="W5.TButton")
19443  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
19444  ModeBMenu["menu"] = ModeBMenu.menu
19445  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
19446  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
19447  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
19448  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
19449  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
19450  ModeBMenu.menu.add_separator()
19451  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
19452  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
19453  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
19454  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
19455  ModeBMenu.pack(side=LEFT, anchor=W)
19456  ShapeBMenu = Menubutton(awg2eb, text="Shape", style="W6.TButton")
19457  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
19458  ShapeBMenu["menu"] = ShapeBMenu.menu
19459  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
19460  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
19461  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
19462  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
19463  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
19464  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
19465  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
19466  if AWGShowAdvanced.get() > 0:
19467  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
19468  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
19469  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
19470  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
19471  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
19472  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
19473  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
19474  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
19475  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
19476  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
19477  ShapeBMenu.menu.add_radiobutton(label="Full Wave", variable=AWGBShape, value=23, command=ReMakeAWGwaves)
19478  ShapeBMenu.menu.add_radiobutton(label="Half Wave", variable=AWGBShape, value=24, command=ReMakeAWGwaves)
19479  # These stand alone shapes are now redundant, use add noise to 0 amplt sine
19480  # ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
19481  # ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
19482  else:
19483  ShapeBMenu.menu.add_separator()
19484  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
19485  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
19486  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
19487  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
19488  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
19489  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
19490  ShapeBMenu.pack(side=LEFT, anchor=W)
19491  #
19492  AWGBModeLabel = Label(frame3, text="AWG B Mode")
19493  AWGBModeLabel.pack(side=TOP)
19494  AWGBShapeLabel = Label(frame3, text="AWG B Shape")
19495  AWGBShapeLabel.pack(side=TOP)
19496  #
19497  awg2ampl = Frame( frame3 )
19498  awg2ampl.pack(side=TOP)
19499  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
19500  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
19501  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
19502  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19503  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
19504  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
19505  AWGBAmplEntry.pack(side=LEFT, anchor=W)
19506  AWGBAmplEntry.delete(0,"end")
19507  AWGBAmplEntry.insert(0,0.0)
19508  amp2lab = Label(awg2ampl) #, text="Min Ch B")
19509  amp2lab.pack(side=LEFT, anchor=W)
19510  #
19511  awg2off = Frame( frame3 )
19512  awg2off.pack(side=TOP)
19513  AWGBOffsetEntry = Entry(awg2off, width=5, cursor='double_arrow')
19514  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
19515  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
19516  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19517  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
19518  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
19519  AWGBOffsetEntry.pack(side=LEFT, anchor=W)
19520  AWGBOffsetEntry.delete(0,"end")
19521  AWGBOffsetEntry.insert(0,0.0)
19522  off2lab = Label(awg2off) #, text="Max Ch B")
19523  off2lab.pack(side=LEFT, anchor=W)
19524  if AWG_Amp_Mode.get() == 0:
19525  amp2lab.config(text = "Min Ch B" ) # change displayed value
19526  off2lab.config(text = "Max Ch B" ) # change displayed value
19527  else:
19528  amp2lab.config(text = "Amp Ch B" )
19529  off2lab.config(text = "Off Ch B" )
19530  # AWG Frequency sub frame
19531  awg2freq = Frame( frame3 )
19532  awg2freq.pack(side=TOP)
19533  AWGBFreqEntry = Entry(awg2freq, width=7, cursor='double_arrow')
19534  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
19535  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
19536  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19537  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
19538  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
19539  AWGBFreqEntry.pack(side=LEFT, anchor=W)
19540  AWGBFreqEntry.delete(0,"end")
19541  AWGBFreqEntry.insert(0,100.0)
19542  freq2lab = Label(awg2freq, text="Freq Ch B")
19543  freq2lab.pack(side=LEFT, anchor=W)
19544  # AWG Phase or delay select sub frame
19545  # AWG Phase sub frame
19546  awg2phase = Frame( frame3 )
19547  awg2phase.pack(side=TOP)
19548  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
19549  awgbph.pack(side=LEFT, anchor=W)
19550  AWGBPhaseEntry = Entry(awg2phase, width=4, cursor='double_arrow')
19551  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
19552  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
19553  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19554  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
19555  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
19556  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
19557  AWGBPhaseEntry.delete(0,"end")
19558  AWGBPhaseEntry.insert(0,0)
19559  phaseblab = Label(awg2phase, text="Deg")
19560  phaseblab.pack(side=LEFT, anchor=W)
19561  # AWG duty cycle frame
19562  awg2dc = Frame( frame3 )
19563  awg2dc.pack(side=TOP)
19564  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
19565  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
19566  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
19567  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19568  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
19569  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
19570  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
19571  AWGBDutyCycleEntry.delete(0,"end")
19572  AWGBDutyCycleEntry.insert(0,50)
19573  duty2lab = Label(awg2dc, text="%")
19574  duty2lab.pack(side=LEFT, anchor=W)
19575  #
19576  AWGBLength = Label(frame3, text="Length")
19577  AWGBLength.pack(side=TOP)
19578  # Noise Controls
19579  bnoise = Frame( frame3 )
19580  bnoise.pack(side=TOP)
19581  AWGBNoise = Label(bnoise, text="Noise")
19582  AWGBNoise.pack(side=LEFT, anchor=W)
19583  AWGBsbnoise = Spinbox(bnoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
19584  AWGBsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
19585  AWGBsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19586  AWGBsbnoise.bind("<Button-5>", onSpinBoxScroll)
19587  AWGBsbnoise.pack(side=LEFT, anchor=W)
19588  AWGBNoiseEntry = Entry(bnoise, width=5, cursor='double_arrow')
19589  AWGBNoiseEntry.bind("<Return>", UpdateAwgContRet)
19590  AWGBNoiseEntry.bind('<MouseWheel>', onAWGBscroll)
19591  AWGBNoiseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19592  AWGBNoiseEntry.bind("<Button-5>", onAWGBscroll)
19593  AWGBNoiseEntry.bind('<Key>', onTextKeyAWG)
19594  AWGBNoiseEntry.pack(side=LEFT, anchor=W)
19595  AWGBNoiseEntry.delete(0,"end")
19596  AWGBNoiseEntry.insert(0,0.0)
19597  #
19598  bcompa = Checkbutton(frame3, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)#SetBCompA)
19599  bcompa.pack(side=TOP)
19600  if FWRevOne > 2.16:
19601  awgsync = Checkbutton(frame3, text="Sync AWG", variable=AWGSync, command=BAWGSync)
19602  awgsync.pack(side=TOP)
19603  #
19604  dismissbutton = Button(frame3, text="Minimize", style="W8.TButton", command=DestroyAWGScreen)
19605  dismissbutton.pack(side=TOP)
19606  if ShowBallonHelp > 0:
19607  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
19608  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
19609  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
19610  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
19611  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
19612  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
19613  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
19614  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
19615  else:
19616  awgwindow.deiconify()
19617 #
19618 def BAWG2X():
19619  global AWG_2X, devx, AWGAIOMode, AWGBIOMode, BisCompA
19620 
19621  ReMakeAWGwaves()
19622  if AWG_2X.get() == 0: # configure board for both AWG channels at 1X sampling
19623  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
19624  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
19625  elif AWG_2X.get() == 1: # configure board for single AWG channel A at 2X sampling
19626  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
19627  devx.ctrl_transfer(0x40, 0x25, 0x0, 0, 0, 0, 100) # set t0 addr DAC A
19628  if AWGBIOMode.get() == 0: # if channel b is not in split I/O mode turn off output
19629  devx.ctrl_transfer(0x40, 0x51, 40, 0, 0, 0, 100) # set IN3 switch to open
19630  devx.ctrl_transfer(0x40, 0x51, 52, 0, 0, 0, 100) # set IN3 switch to open
19631  BisCompA.set(0)
19632  elif AWG_2X.get() == 2: # configure board for single AWG channel B at 2X sampling
19633  devx.ctrl_transfer(0x40, 0x24, 0x1, 0, 0, 0, 100) # set to addr DAC B
19634  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
19635  if AWGAIOMode.get() == 0: # if channel a is not in split I/O mode turn off output
19636  devx.ctrl_transfer(0x40, 0x51, 35, 0, 0, 0, 100) # set IN3 switch to open
19637  devx.ctrl_transfer(0x40, 0x51, 51, 0, 0, 0, 100) # set IN3 switch to open
19638  BisCompA.set(0)
19639 #
19640 def DestroyAWGScreen():
19641  global awgwindow, AWGScreenStatus
19642 
19643  # AWGScreenStatus.set(0)
19644  awgwindow.iconify()
19645 #
19646 # ===== Channel B Mux Mode sub Window =======
19647 def MakeMuxModeWindow():
19648  global MuxScreenStatus, muxwindow, RevDate, DacScreenStatus, DigScreenStatus
19649  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
19650  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, SyncButton
19651  global CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab, CHBlab, CHBofflab
19652  global CHB_cba, CHB_cbb, CHB_cbc, CHB_cbd
19653  global CHB_Cofflab, CHB_Dofflab, awgsync, SWRev, BorderSize
19654  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb, MuxSync, hipulseimg, lowpulseimg
19655  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
19656  global ChopMuxMode, ChopTrig, DualMuxMode, ShowBallonHelp
19657 
19658  if MuxScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0:
19659  MuxScreenStatus.set(1)
19660  #
19661  BAWGEnab() # update AWG settings
19662  #
19663  muxwindow = Toplevel()
19664  muxwindow.title("External Mux " + SWRev + RevDate)
19665  muxwindow.resizable(FALSE,FALSE)
19666  muxwindow.protocol("WM_DELETE_WINDOW", DestroyMuxScreen)
19667  #
19668  frameM = LabelFrame(muxwindow, text="External Analog Mux", style="A10.TLabelframe") #
19669  frameM.pack(side=LEFT, expand=1, fill=X)
19670  #
19671  # Voltage channel CHB-A
19672  frameA = Frame(frameM)
19673  frameA.pack(side=TOP)
19674  CHB_cba = Checkbutton(frameA, text='CB-A', style="Strace2.TCheckbutton", variable=Show_CBA, command=UpdateTimeTrace)
19675  CHB_cba.pack(side=LEFT, anchor=W)
19676  CHB_Asb = Spinbox(frameA, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
19677  CHB_Asb.bind('<MouseWheel>', onSpinBoxScroll)
19678  CHB_Asb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19679  CHB_Asb.bind("<Button-5>", onSpinBoxScroll)
19680  CHB_Asb.pack(side=LEFT)
19681  CHB_Asb.delete(0,"end")
19682  CHB_Asb.insert(0,0.5)
19683  #
19684  CHB_Alab = Button(frameA, text="CB-A V/Div", style="Rtrace2.TButton", command=SetScaleMuxA)
19685  CHB_Alab.pack(side=LEFT)
19686  CHB_APosEntry = Entry(frameA, width=5, cursor='double_arrow')
19687  CHB_APosEntry.bind('<Return>', onTextKey)
19688  CHB_APosEntry.bind('<MouseWheel>', onTextScroll)
19689  CHB_APosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19690  CHB_APosEntry.bind("<Button-5>", onTextScroll)
19691  CHB_APosEntry.bind('<Key>', onTextKey)
19692  CHB_APosEntry.pack(side=LEFT)
19693  CHB_APosEntry.delete(0,"end")
19694  CHB_APosEntry.insert(0,2.5)
19695  CHB_Aofflab = Button(frameA, text="CB-A Pos", style="Rtrace2.TButton", command=SetMuxAPoss)
19696  CHB_Aofflab.pack(side=LEFT)
19697  # Voltage channel CHB-B
19698  frameB = Frame(frameM)
19699  frameB.pack(side=TOP)
19700  CHB_cbb = Checkbutton(frameB, text='CB-B', style="Strace6.TCheckbutton", variable=Show_CBB, command=UpdateTimeTrace)
19701  CHB_cbb.pack(side=LEFT, anchor=W)
19702  CHB_Bsb = Spinbox(frameB, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
19703  CHB_Bsb.bind('<MouseWheel>', onSpinBoxScroll)
19704  CHB_Bsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19705  CHB_Bsb.bind("<Button-5>", onSpinBoxScroll)
19706  CHB_Bsb.pack(side=LEFT)
19707  CHB_Bsb.delete(0,"end")
19708  CHB_Bsb.insert(0,0.5)
19709  CHB_Blab = Button(frameB, text="CB-B V/Div", style="Rtrace6.TButton", command=SetScaleMuxB)
19710  CHB_Blab.pack(side=LEFT)
19711  CHB_BPosEntry = Entry(frameB, width=5, cursor='double_arrow')
19712  CHB_BPosEntry.bind('<Return>', onTextKey)
19713  CHB_BPosEntry.bind('<MouseWheel>', onTextScroll)
19714  CHB_BPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19715  CHB_BPosEntry.bind("<Button-5>", onTextScroll)
19716  CHB_BPosEntry.bind('<Key>', onTextKey)
19717  CHB_BPosEntry.pack(side=LEFT)
19718  CHB_BPosEntry.delete(0,"end")
19719  CHB_BPosEntry.insert(0,2.5)
19720  CHB_Bofflab = Button(frameB, text="CB-B Pos", style="Rtrace6.TButton", command=SetMuxBPoss)
19721  CHB_Bofflab.pack(side=LEFT)
19722  # Voltage channel B-C
19723  frameC = Frame(frameM)
19724  frameC.pack(side=TOP)
19725  CHB_cbc = Checkbutton(frameC, text='CB-C', style="Strace7.TCheckbutton", variable=Show_CBC, command=UpdateTimeTrace)
19726  CHB_cbc.pack(side=LEFT, anchor=W)
19727  CHB_Csb = Spinbox(frameC, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
19728  CHB_Csb.bind('<MouseWheel>', onSpinBoxScroll)
19729  CHB_Csb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19730  CHB_Csb.bind("<Button-5>", onSpinBoxScroll)
19731  CHB_Csb.pack(side=LEFT)
19732  CHB_Csb.delete(0,"end")
19733  CHB_Csb.insert(0,0.5)
19734  #
19735  CHB_Clab = Button(frameC, text="CB-C V/Div", style="Rtrace7.TButton", command=SetScaleMuxC)
19736  CHB_Clab.pack(side=LEFT)
19737  CHB_CPosEntry = Entry(frameC, width=5, cursor='double_arrow')
19738  CHB_CPosEntry.bind('<Return>', onTextKey)
19739  CHB_CPosEntry.bind('<MouseWheel>', onTextScroll)
19740  CHB_CPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19741  CHB_CPosEntry.bind("<Button-5>", onTextScroll)
19742  CHB_CPosEntry.bind('<Key>', onTextKey)
19743  CHB_CPosEntry.pack(side=LEFT)
19744  CHB_CPosEntry.delete(0,"end")
19745  CHB_CPosEntry.insert(0,2.5)
19746  CHB_Cofflab = Button(frameC, text="CB-C Pos", style="Rtrace7.TButton", command=SetMuxCPoss)
19747  CHB_Cofflab.pack(side=LEFT)
19748  # Voltage channel B-D
19749  frameD = Frame(frameM)
19750  frameD.pack(side=TOP)
19751  CHB_cbd = Checkbutton(frameD, text='CB-D', style="Strace4.TCheckbutton", variable=Show_CBD, command=UpdateTimeTrace)
19752  CHB_cbd.pack(side=LEFT, anchor=W)
19753  CHB_Dsb = Spinbox(frameD, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
19754  CHB_Dsb.bind('<MouseWheel>', onSpinBoxScroll)
19755  CHB_Dsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19756  CHB_Dsb.bind("<Button-5>", onSpinBoxScroll)
19757  CHB_Dsb.pack(side=LEFT)
19758  CHB_Dsb.delete(0,"end")
19759  CHB_Dsb.insert(0,0.5)
19760  CHB_Dlab = Button(frameD, text="CB-D V/Div", style="Rtrace4.TButton", command=SetScaleMuxD)
19761  CHB_Dlab.pack(side=LEFT)
19762  CHB_DPosEntry = Entry(frameD, width=5, cursor='double_arrow')
19763  CHB_DPosEntry.bind('<Return>', onTextKey)
19764  CHB_DPosEntry.bind('<MouseWheel>', onTextScroll)
19765  CHB_DPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19766  CHB_DPosEntry.bind("<Button-5>", onTextScroll)
19767  CHB_DPosEntry.bind('<Key>', onTextKey)
19768  CHB_DPosEntry.pack(side=LEFT)
19769  CHB_DPosEntry.delete(0,"end")
19770  CHB_DPosEntry.insert(0,2.5)
19771  CHB_Dofflab = Button(frameD, text="CB-D Pos", style="Rtrace4.TButton", command=SetMuxDPoss)
19772  CHB_Dofflab.pack(side=LEFT)
19773  #
19774  frameR = Frame(frameM)
19775  frameR.pack(side=TOP)
19776  RefTraceMenu = Menubutton(frameR, text="Reference Traces", width=17, style="W17.TButton")
19777  RefTraceMenu.menu = Menu(RefTraceMenu, tearoff = 0 )
19778  RefTraceMenu["menu"] = RefTraceMenu.menu
19779  RefTraceMenu.menu.add_command(label="-Take Snap Shot", command=BSnapShot)
19780  RefTraceMenu.menu.add_command(label="-Ref MUX trace-", foreground="blue", command=donothing)
19781  RefTraceMenu.menu.add_checkbutton(label='RMuxA', background=COLORtraceR2, variable=ShowRMA, command=UpdateTimeTrace)
19782  RefTraceMenu.menu.add_checkbutton(label='RMuxB', background=COLORtraceR6, variable=ShowRMB, command=UpdateTimeTrace)
19783  RefTraceMenu.menu.add_checkbutton(label='RMuxC', background=COLORtraceR7, variable=ShowRMC, command=UpdateTimeTrace)
19784  RefTraceMenu.menu.add_checkbutton(label='RMuxD', background=COLORtraceR4, variable=ShowRMD, command=UpdateTimeTrace)
19785  RefTraceMenu.pack(side=LEFT)
19786  #
19787  frameE = Frame(frameM)
19788  frameE.pack(side=TOP)
19789  muxenab = Checkbutton(frameE, text="Mux-Enb", variable=MuxEnb)
19790  muxenab.pack(side=LEFT)
19791  SyncButton = Checkbutton(frameE, compound=TOP, image=hipulseimg, variable=MuxSync, command=SyncImage)
19792  SyncButton.pack(side=LEFT)
19793  dismissbutton = Button(frameE, text="Dismiss", style="W8.TButton", command=DestroyMuxScreen)
19794  dismissbutton.pack(side=LEFT)
19795  frameF = Frame(frameM)
19796  frameF.pack(side=TOP)
19797  dmx = Checkbutton(frameF, text='Dual Mux Split I/O mode', variable=DualMuxMode, command=SetDualMuxMode)
19798  dmx.pack(side=LEFT)
19799  frameCH = Frame(frameM)
19800  frameCH.pack(side=TOP)
19801  altmx = Radiobutton(frameCH, text='Alternate Sweep', variable=ChopMuxMode, value=0, command=SetChopMuxMode)
19802  altmx.pack(side=LEFT)
19803  chopmx = Radiobutton(frameCH, text='Chop Sweep', variable=ChopMuxMode, value=1, command=SetChopMuxMode)
19804  chopmx.pack(side=LEFT)
19805  frameCT = Frame(frameM)
19806  frameCT.pack(side=TOP)
19807  # Chope Mode trigger drop-down
19808  ChopTrigMenu = Menubutton(frameCT, text="Chop Mode Trigger", width=17, style="W17.TButton")
19809  ChopTrigMenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
19810  ChopTrigMenu["menu"] = ChopTrigMenu.menu
19811  ChopTrigMenu.menu.add_command(label="-MUX Chan-", foreground="blue", command=donothing)
19812  ChopTrigMenu.menu.add_radiobutton(label="None", variable=ChopTrig, value=0) #, command=BAWGBModeLabel)
19813  ChopTrigMenu.menu.add_radiobutton(label="Mux A", variable=ChopTrig, value=1) #, command=BAWGBModeLabel)
19814  ChopTrigMenu.menu.add_radiobutton(label="Mux B", variable=ChopTrig, value=2) #, command=BAWGBModeLabel)
19815  ChopTrigMenu.menu.add_radiobutton(label="Mux C", variable=ChopTrig, value=3) #, command=BAWGBModeLabel)
19816  ChopTrigMenu.menu.add_radiobutton(label="Mux D", variable=ChopTrig, value=4) #, command=BAWGBModeLabel)
19817  ChopTrigMenu.pack(side=LEFT)
19818  #
19819  SaveMuxmenu = Menubutton(frameCT, text="Export csv", width=10, style="W17.TButton")
19820  SaveMuxmenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
19821  SaveMuxmenu["menu"] = SaveMuxmenu.menu
19822  SaveMuxmenu.menu.add_command(label="Save Mux traces", command=BSaveMuxData)
19823  SaveMuxmenu.menu.add_command(label="Save single channel", command=BSaveChannelData)
19824  SaveMuxmenu.pack(side=LEFT)
19825  # Gray out main Channel B controls
19826  CHBlab.config(style="SGray.TButton")
19827  CHBofflab.config(style="SGray.TButton")
19828 
19829  #
19830  if ShowBallonHelp > 0:
19831  CHB_Alab_tip = CreateToolTip(CHB_Alab, 'Select CB-A vertical range/position axis to be used for markers and drawn color')
19832  CHB_Blab_tip = CreateToolTip(CHB_Blab, 'Select CB-B vertical range/position axis to be used for markers and drawn color')
19833  CHB_Clab_tip = CreateToolTip(CHB_Clab, 'Select CB-C vertical range/position axis to be used for markers and drawn color')
19834  CHB_Dlab_tip = CreateToolTip(CHB_Dlab, 'Select CB-D vertical range/position axis to be used for markers and drawn color')
19835  CHB_Aofflab_tip = CreateToolTip(CHB_Aofflab, 'Set CB-A position to DC average of signal')
19836  CHB_Bofflab_tip = CreateToolTip(CHB_Bofflab, 'Set CB-B position to DC average of signal')
19837  CHB_Cofflab_tip = CreateToolTip(CHB_Cofflab, 'Set CB-C position to DC average of signal')
19838  CHB_Dofflab_tip = CreateToolTip(CHB_Dofflab, 'Set CB-D position to DC average of signal')
19839  ChopTrigMenu_tip = CreateToolTip(ChopTrigMenu, 'Menu to Select Trigger Source')
19840  RefTraceMenu_tip = CreateToolTip(RefTraceMenu, 'Menu to Select Mux Reference Traces')
19841  SaveMuxmenu_tip = CreateToolTip(SaveMuxmenu, 'Menu to Export Mux Trace Data to .csv file')
19842 #
19843 def SetDualMuxMode():
19844  global AWGAIOMode, AWGBIOMode, ShowC1_V, DualMuxMode, CHAlab, CHAofflab
19845  global CHB_Clab, CHB_Dlab, CHB_Cofflab, CHB_Dofflab, CHB_cbc, CHB_cbd
19846 
19847  if DualMuxMode.get() == 1:
19848  AWGAIOMode.set(1) # force awg A split I/O mode
19849  AWGBIOMode.set(1) # force awg B split I/O mode
19850  ShowC1_V.set(0) # force A voltage trace off
19851  CHB_cbc.config(text="CA-C")
19852  CHB_cbd.config(text="CA-D")
19853  CHB_Clab.config(text="CA-C V/Div")
19854  CHB_Dlab.config(text="CA-D V/Div")
19855  CHB_Cofflab.config(text="CA-C Pos")
19856  CHB_Dofflab.config(text="CA-D Pos")
19857  BAWGEnab() # update AWG settings
19858  # Gray out main Channel A controls
19859  CHAlab.config(style="SGray.TButton")
19860  CHAofflab.config(style="SGray.TButton")
19861  else:
19862  ShowC1_V.set(1) # force A voltage trace on
19863  CHB_cbc.config(text="CB-C")
19864  CHB_cbd.config(text="CB-D")
19865  CHB_Clab.config(text="CB-C V/Div")
19866  CHB_Dlab.config(text="CB-D V/Div")
19867  CHB_Cofflab.config(text="CB-C Pos")
19868  CHB_Dofflab.config(text="CB-D Pos")
19869  # Reset main Channel A control colors
19870  CHAlab.config(style="Rtrace1.TButton")
19871  CHAofflab.config(style="Rtrace1.TButton")
19872 #
19873 def SetChopMuxMode():
19874  global ChopMuxMode, AWGAIOMode, AWGBIOMode, AWGAMode, AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry
19875  global AWGAPhaseEntry, SAMPLErate, ShowC1_V, ShowC2_V, TgInput
19876 
19877  if ChopMuxMode.get() > 0: # set AWG A to a square wave at 25 KHz 0.5 to 4.5 V, mode = SVMI_SPLIT
19878  AWGAIOMode.set(1) # force awg A split I/O mode
19879  AWGAMode.set(0) # force awg A mode to SVMI
19880  BAWGAModeLabel()
19881  AWGAShape.set(4) # force awg A to square shape
19882  AWGAAmplEntry.delete(0,"end")
19883  AWGAAmplEntry.insert(0,0.5) # force awg A Min value to 0.5 V
19884  AWGAOffsetEntry.delete(0,"end")
19885  AWGAOffsetEntry.insert(0,4.5) # force awg A Max value to 4.5 V
19886  AWGAFreqEntry.delete(0,"end")
19887  AWGAFreqEntry.insert(0,SAMPLErate/4) # force awg A Freg value to 25000 (1/4 base sample rate)
19888  AWGAPhaseEntry.delete(0,"end")
19889  AWGAPhaseEntry.insert(0,0) # force awg A Phase value to 0
19890  ReMakeAWGwaves()
19891  AWGBIOMode.set(1) # force awg A split I/O mode
19892  BAWGBModeLabel()
19893  ShowC1_V.set(0) # force A voltage trace off
19894  ShowC2_V.set(0) # force B voltage trace off
19895  TgInput.set(0) # force main Trigger source to none
19896  CHAlab.config(style="SGray.TButton")
19897  CHAofflab.config(style="SGray.TButton")
19898  else:
19899  CHAlab.config(style="Rtrace1.TButton")
19900  CHAofflab.config(style="Rtrace1.TButton")
19901 
19902 def SyncImage():
19903  global MuxSync, hipulseimg, lowpulseimg, SyncButton
19904 
19905  if MuxSync.get() == 0:
19906  SyncButton.config(image=hipulseimg)
19907  else:
19908  SyncButton.config(image=lowpulseimg)
19909 
19910 def DestroyMuxScreen():
19911  global muxwindow, awgsync, MuxScreenStatus, CHAlab, CHAofflab, CHBlab, CHBofflab
19912  global ChopTrig, ChopMuxMode, MarkerScale
19913 
19914  MuxScreenStatus.set(0)
19915  awgsync.config(state=NORMAL)
19916  ChopMuxMode.set(0)
19917  ChopTrig.set(0)
19918  MarkerScale.set(0)
19919  # Reset main Channel B control colors
19920  CHBlab.config(style="Rtrace2.TButton")
19921  CHBofflab.config(style="Rtrace2.TButton")
19922  CHAlab.config(style="Rtrace1.TButton")
19923  CHAofflab.config(style="Rtrace1.TButton")
19924  muxwindow.destroy()
19925 #
19926 def BodeCaresize(event):
19927  global Bodeca, GRWBP, XOLBP, GRHBP, Y0TBP, CANVASwidthBP, CANVASheightBP, FontSize
19928 
19929  CANVASwidthBP = event.width - 4
19930  CANVASheightBP = event.height - 4
19931  GRWBP = CANVASwidthBP - (2 * X0LBP) # new grid width
19932  GRHBP = CANVASheightBP - int(10 * FontSize) # new grid height
19933  UpdateBodeAll()
19934 #
19935 def BStepSync():
19936  global FStepSync, DevOne
19937 
19938  if FStepSync.get() == 0:
19939  Tval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO-0 to Z
19940  elif FStepSync.get() == 1:
19941  devx.ctrl_transfer( 0x40, 0x50, 0, 0, 0, 0, 100) # set PIO-0 to 0
19942  elif FStepSync.get() == 2:
19943  devx.ctrl_transfer( 0x40, 0x51, 0, 0, 0, 0, 100) # set PIO-0 to 1
19944 #
19945 def BSweepSync():
19946  global FSweepSync, DevOne
19947 
19948  if FSweepSync.get() == 0:
19949  Tval = devx.ctrl_transfer( 0xc0, 0x91, 1, 0, 0, 1, 100) # set PIO-1 to Z
19950  elif FSweepSync.get() == 1:
19951  devx.ctrl_transfer( 0x40, 0x50, 1, 0, 0, 0, 100) # set PIO-1 to 0
19952  elif FSweepSync.get() == 2:
19953  devx.ctrl_transfer( 0x40, 0x51, 1, 0, 0, 0, 100) # set PIO-1 to 1
19954 #
19955 def BDSweepFromFile():
19956  global BDSweepFile, FileSweepFreq, FileSweepAmpl
19957 
19958  if BDSweepFile.get() > 0:
19959  # Read values from CVS file
19960  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent = bodewindow)
19961  try:
19962  CSVFile = open(filename)
19963  csv_f = csv.reader(CSVFile)
19964  FileSweepFreq = []
19965  FileSweepAmpl = []
19966  for row in csv_f:
19967  try:
19968  FileSweepFreq.append(float(row[0]))
19969  FileSweepAmpl.append(float(row[1]))
19970  except:
19971  print( 'skipping non-numeric row')
19972  FileSweepFreq = numpy.array(FileSweepFreq)
19973  FileSweepAmpl = numpy.array(FileSweepAmpl)
19974  MaxAmpl = numpy.amax(FileSweepAmpl)
19975  NormAmpl = MaxAmpl
19976  s = askstring("Normalize Max Amplitude", "Max Amplitude = " + str(MaxAmpl) + "\n\n Enter New Max value:\n in dB", parent = bodewindow)
19977  if (s == None): # If Cancel pressed, then None
19978  return()
19979  try: # Error if for example no numeric characters or OK pressed without input (s = "")
19980  v = int(s)
19981  except:
19982  s = "error"
19983 
19984  if s != "error":
19985  NormAmpl = MaxAmpl - v
19986  else:
19987  NormAmpl = MaxAmpl
19988  FileSweepAmpl = FileSweepAmpl - NormAmpl # normalize max amplitude to requested dBV
19989  CSVFile.close()
19990  StopBodeEntry.delete(0,"end")
19991  StopBodeEntry.insert(0,FileSweepFreq[len(FileSweepFreq)-1])
19992  StartBodeEntry.delete(0,"end")
19993  StartBodeEntry.insert(0,FileSweepFreq[0])
19994  SweepStepBodeEntry.delete(0,"end")
19995  SweepStepBodeEntry.insert(0,len(FileSweepFreq))
19996  except:
19997  showwarning("WARNING","No such file found or wrong format!", parent = bodewindow)
19998 #
19999 # ========== Make Bode Plot Window =============
20000 def MakeBodeWindow():
20001  global logo, SmoothCurvesBP, CutDC, bodewindow, SWRev
20002  global CANVASwidthBP, CANVASheightBP, FFTwindow, CutDC, AWGAMode, AWGAShape, AWGBMode
20003  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp, RelPhaseCenter
20004  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP, PhCenBodeEntry
20005  global BPSweepMode, BPSweepCont, Bodeca, BodeScreenStatus, RevDate, SweepStepBodeEntry
20006  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
20007  global GRWBP, GRHBP, X0LBP, FStepSync, FSweepSync, BDSweepFile, MinigenScreenStatus
20008  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, ImpedanceCenter, ImCenBodeEntry
20009  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
20010  global FrameRefief, BorderSize, LocalLanguage
20011  global sbode_tip, rbode_tip, bd3_tip, bd4_tip, bd5_tip, bd6_tip, bd7_tip, bd8_tip, bodismiss1button_tip
20012  global bstopfreqlab, bstartfreqlab, ImCenlab, BPhCenlab
20013 
20014  if BodeScreenStatus.get() == 0:
20015  BodeScreenStatus.set(1)
20016  BodeDisp.set(1)
20017  BodeCheckBox()
20018  CANVASwidthBP = GRWBP + 2 * X0LBP # The Bode canvas width
20019  CANVASheightBP = GRHBP + int(10 * FontSize) # The bode canvas height
20020  CutDC.set(1) # set to remove DC
20021  AWGAMode.set(0) # Set AWG A to SVMI
20022  AWGAShape.set(1) # Set Shape to Sine
20023  AWGBMode.set(2) # Set AWG B to Hi-Z
20024  bodewindow = Toplevel()
20025  bodewindow.title("Bode Plotter " + SWRev + RevDate)
20026  bodewindow.protocol("WM_DELETE_WINDOW", DestroyBodeScreen)
20027  frame2bp = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
20028  frame2bp.pack(side=RIGHT, expand=NO, fill=BOTH)
20029 
20030  frame2b = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
20031  frame2b.pack(side=TOP, expand=YES, fill=BOTH)
20032 
20033  Bodeca = Canvas(frame2b, width=CANVASwidthBP, height=CANVASheightBP, background=COLORcanvas, cursor='cross')
20034  Bodeca.bind('<Configure>', BodeCaresize)
20035  Bodeca.bind('<1>', onCanvasBodeLeftClick)
20036  Bodeca.bind('<3>', onCanvasBodeRightClick)
20037  Bodeca.bind("<Up>", onCanvasUpArrow)
20038  Bodeca.bind("<Down>", onCanvasDownArrow)
20039  Bodeca.bind("<Left>", onCanvasLeftArrow)
20040  Bodeca.bind("<Right>", onCanvasRightArrow)
20041  Bodeca.bind("<space>", onCanvasSpaceBar)
20042  Bodeca.bind("1", onCanvasBdOne)
20043  Bodeca.bind("2", onCanvasBdTwo)
20044  Bodeca.bind("3", onCanvasBdThree)
20045  Bodeca.bind("4", onCanvasBdFour)
20046  Bodeca.bind("5", onCanvasBdFive)
20047  Bodeca.bind("6", onCanvasBdSix)
20048  Bodeca.bind("7", onCanvasBdSeven)
20049  Bodeca.bind("8", onCanvasBdEight)
20050  Bodeca.bind("9", onCanvasBdNine)
20051  Bodeca.bind("0", onCanvasBdZero)
20052  Bodeca.bind("f", onCanvasShowBPcur)
20053  Bodeca.bind("d", onCanvasShowBdBcur)
20054  Bodeca.bind("h", onCanvasShowPdBcur)
20055  Bodeca.bind("s", onCanvasBdSnap)
20056  Bodeca.pack(side=TOP, expand=YES, fill=BOTH)
20057 
20058  # right side drop down menu buttons
20059  dropmenu = Frame( frame2bp )
20060  dropmenu.pack(side=TOP)
20061  # File menu
20062  BodeFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
20063  BodeFilemenu.menu = Menu(BodeFilemenu, tearoff = 0 )
20064  BodeFilemenu["menu"] = BodeFilemenu.menu
20065  BodeFilemenu.menu.add_command(label="Save Config", command=BSaveConfigBP)
20066  BodeFilemenu.menu.add_command(label="Load Config", command=BLoadConfigBP)
20067  BodeFilemenu.menu.add_command(label="Run Script", command=RunScript)
20068  BodeFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenBP)
20069  BodeFilemenu.menu.add_command(label="Save Data", command=BCSVfile)
20070  BodeFilemenu.pack(side=LEFT, anchor=W)
20071  #
20072  BodeOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
20073  BodeOptionmenu.menu = Menu(BodeOptionmenu, tearoff = 0 )
20074  BodeOptionmenu["menu"] = BodeOptionmenu.menu
20075  BodeOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
20076  BodeOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesBP)
20077  BodeOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
20078  BodeOptionmenu.menu.add_command(label="Store trace (s)", command=BSTOREtraceBP)
20079  BodeOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
20080  BodeOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
20081  BodeOptionmenu.menu.add_command(label="-Step Sync Pulse-", command=donothing)
20082  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FStepSync, value=0, command=BStepSync)
20083  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FStepSync, value=1, command=BStepSync)
20084  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FStepSync, value=2, command=BStepSync)
20085  BodeOptionmenu.menu.add_command(label="-Sweep Sync Pulse-", command=donothing)
20086  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FSweepSync, value=0, command=BSweepSync)
20087  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FSweepSync, value=1, command=BSweepSync)
20088  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FSweepSync, value=2, command=BSweepSync)
20089  BodeOptionmenu.pack(side=LEFT, anchor=W)
20090  #
20091  RUNframe = Frame( frame2bp )
20092  RUNframe.pack(side=TOP)
20093  rbode = Button(RUNframe, text="Run", style="Run.TButton", command=BStartBP)
20094  rbode.pack(side=LEFT)
20095  sbode = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopBP)
20096  sbode.pack(side=LEFT)
20097  #
20098  BodeFFTwindmenu = Menubutton(frame2bp, text="FFTwindow", style="W11.TButton")
20099  BodeFFTwindmenu.menu = Menu(BodeFFTwindmenu, tearoff = 0 )
20100  BodeFFTwindmenu["menu"] = BodeFFTwindmenu.menu
20101  BodeFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
20102  BodeFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
20103  BodeFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
20104  BodeFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
20105  BodeFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
20106  BodeFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
20107  BodeFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
20108  BodeFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
20109  BodeFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
20110  BodeFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
20111  BodeFFTwindmenu.pack(side=TOP)
20112  #
20113  tracemenu = Frame( frame2bp )
20114  tracemenu.pack(side=TOP)
20115  # Curves menu
20116  # Show channels menu
20117  BodeShowmenu = Menubutton(tracemenu, text="Curves", style="W7.TButton")
20118  BodeShowmenu.menu = Menu(BodeShowmenu, tearoff = 0 )
20119  BodeShowmenu["menu"] = BodeShowmenu.menu
20120  BodeShowmenu.menu.add_command(label="-Show-", command=donothing)
20121  BodeShowmenu.menu.add_command(label="All", command=BShowCurvesAllBP)
20122  BodeShowmenu.menu.add_command(label="None", command=BShowCurvesNoneBP)
20123  BodeShowmenu.menu.add_checkbutton(label='CA-dBV (1)', variable=ShowCA_VdB, command=UpdateBodeAll)
20124  BodeShowmenu.menu.add_checkbutton(label='CB-dBV (2)', variable=ShowCB_VdB, command=UpdateBodeAll)
20125  BodeShowmenu.menu.add_checkbutton(label='Phase A-B (3)', variable=ShowCA_P, command=UpdateBodeAll)
20126  BodeShowmenu.menu.add_checkbutton(label='Phase B-A (4)', variable=ShowCB_P, command=UpdateBodeAll)
20127  BodeShowmenu.menu.add_command(label="-Math-", command=donothing)
20128  BodeShowmenu.menu.add_radiobutton(label='None (0)', variable=ShowMathBP, value=0, command=UpdateBodeAll)
20129  BodeShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB (9)', variable=ShowMathBP, value=1, command=UpdateBodeAll)
20130  BodeShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB (8)', variable=ShowMathBP, value=2, command=UpdateBodeAll)
20131  BodeShowmenu.menu.add_command(label="-Impedance-", command=donothing)
20132  BodeShowmenu.menu.add_checkbutton(label='Series R', variable=Show_Rseries, command=UpdateBodeAll)
20133  BodeShowmenu.menu.add_checkbutton(label='Series X', variable=Show_Xseries, command=UpdateBodeAll)
20134  BodeShowmenu.menu.add_checkbutton(label='Series Mag', variable= Show_Magnitude, command=UpdateBodeAll)
20135  BodeShowmenu.menu.add_checkbutton(label='Series Ang', variable=Show_Angle, command=UpdateBodeAll)
20136  BodeShowmenu.menu.add_separator()
20137  BodeShowmenu.menu.add_checkbutton(label='RA-dBV (6)', variable=ShowCA_RdB, command=UpdateBodeAll)
20138  BodeShowmenu.menu.add_checkbutton(label='RB-dBV (7)', variable=ShowCB_RdB, command=UpdateBodeAll)
20139  BodeShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowCA_RP, command=UpdateBodeAll)
20140  BodeShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowCB_RP, command=UpdateBodeAll)
20141  BodeShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMathBP, command=UpdateBodeAll)
20142  BodeShowmenu.menu.add_checkbutton(label='Ref Series R', variable=Show_RseriesRef, command=UpdateBodeAll)
20143  BodeShowmenu.menu.add_checkbutton(label='Ref Series X', variable=Show_XseriesRef, command=UpdateBodeAll)
20144  BodeShowmenu.menu.add_checkbutton(label='Ref Series Mag', variable=Show_MagnitudeRef, command=UpdateBodeAll)
20145  BodeShowmenu.menu.add_checkbutton(label='Ref Series Ang', variable=Show_AngleRef, command=UpdateBodeAll)
20146  BodeShowmenu.pack(side=LEFT, anchor=W)
20147  #
20148  BodeMarkmenu = Menubutton(tracemenu, text="Cursors", style="W7.TButton")
20149  BodeMarkmenu.menu = Menu(BodeMarkmenu, tearoff = 0 )
20150  BodeMarkmenu["menu"] = BodeMarkmenu.menu
20151  BodeMarkmenu.menu.add_command(label="-Cursors&Markers-", command=donothing)
20152  BodeMarkmenu.menu.add_checkbutton(label='Marker (5)', variable=ShowMarkerBP, command=UpdateBodeAll)
20153  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor', variable=ShowBPCur)
20154  BodeMarkmenu.menu.add_checkbutton(label='dB Cursor', variable=ShowBdBCur)
20155  BodeMarkmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowBdBCur, value=0)
20156  BodeMarkmenu.menu.add_radiobutton(label='dB Cursor (d)', variable=ShowBdBCur, value=1)
20157  BodeMarkmenu.menu.add_radiobutton(label='Phase Cursor (h)', variable=ShowBdBCur, value=2)
20158  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor (f)', variable=ShowBPCur)
20159  BodeMarkmenu.pack(side=LEFT, anchor=W)
20160  #
20161  # Horz Scale
20162  HzScale = Frame( frame2bp )
20163  HzScale.pack(side=TOP)
20164  brb1 = Radiobutton(HzScale, text="Lin F", variable=HScaleBP, value=0, command=UpdateBodeTrace )
20165  brb1.pack(side=LEFT)
20166  brb2 = Radiobutton(HzScale, text="Log F", variable=HScaleBP, value=1, command=UpdateBodeTrace )
20167  brb2.pack(side=LEFT)
20168 
20169  DBrange = Frame( frame2bp )
20170  DBrange.pack(side=TOP)
20171  bd3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2BP)
20172  bd3.pack(side=LEFT)
20173  bd4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1BP)
20174  bd4.pack(side=LEFT)
20175 
20176  LVBrange = Frame( frame2bp )
20177  LVBrange.pack(side=TOP)
20178  bd5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4BP)
20179  bd5.pack(side=LEFT)
20180  bd6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3BP)
20181  bd6.pack(side=LEFT)
20182 
20183  LVSrange = Frame( frame2bp )
20184  LVSrange.pack(side=TOP)
20185  bd7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2BP)
20186  bd7.pack(side=LEFT)
20187  bd8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1BP)
20188  bd8.pack(side=LEFT)
20189 
20190  PhaseCenter = Frame( frame2bp )
20191  PhaseCenter.pack(side=TOP)
20192  BPhCenlab = Label(PhaseCenter, text="Center Phase on")
20193  BPhCenlab.pack(side=LEFT)
20194  PhCenBodeEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
20195  PhCenBodeEntry.bind('<Return>', onTextKey)
20196  PhCenBodeEntry.bind('<MouseWheel>', onTextScroll)
20197  PhCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20198  PhCenBodeEntry.bind("<Button-5>", onTextScroll)
20199  PhCenBodeEntry.bind('<Key>', onTextKey)
20200  PhCenBodeEntry.pack(side=LEFT)
20201  PhCenBodeEntry.delete(0,"end")
20202  PhCenBodeEntry.insert(0,RelPhaseCenter.get())
20203  #
20204  ImpedCenter = Frame( frame2bp )
20205  ImpedCenter.pack(side=TOP)
20206  ImCenlab = Label(ImpedCenter, text="Center Imped on")
20207  ImCenlab.pack(side=LEFT)
20208  ImCenBodeEntry = Entry(ImpedCenter, width=5, cursor='double_arrow')
20209  ImCenBodeEntry.bind('<Return>', onTextKey)
20210  ImCenBodeEntry.bind('<MouseWheel>', onTextScroll)
20211  ImCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20212  ImCenBodeEntry.bind("<Button-5>", onTextScroll)
20213  ImCenBodeEntry.bind('<Key>', onTextKey)
20214  ImCenBodeEntry.pack(side=LEFT)
20215  ImCenBodeEntry.delete(0,"end")
20216  ImCenBodeEntry.insert(0,ImpedanceCenter.get())
20217  # sweep generator mode menu buttons
20218  FSweepmenu = Label(frame2bp, text="-Sweep Gen-", style="A10B.TLabel")
20219  FSweepmenu.pack(side=TOP)
20220 
20221  Frange1 = Frame( frame2bp )
20222  Frange1.pack(side=TOP)
20223  bstartfreqlab = Label(Frange1, text="Start Freq")
20224  bstartfreqlab.pack(side=LEFT)
20225  StartBodeEntry = Entry(Frange1, width=5, cursor='double_arrow')
20226  StartBodeEntry.bind('<Return>', onTextKey)
20227  StartBodeEntry.bind('<MouseWheel>', onTextScroll)
20228  StartBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20229  StartBodeEntry.bind("<Button-5>", onTextScroll)
20230  StartBodeEntry.bind('<Key>', onTextKey)
20231  StartBodeEntry.pack(side=LEFT)
20232  StartBodeEntry.delete(0,"end")
20233  StartBodeEntry.insert(0,10)
20234 
20235  Frange2 = Frame( frame2bp )
20236  Frange2.pack(side=TOP)
20237  bstopfreqlab = Label(Frange2, text="Stop Freq")
20238  bstopfreqlab.pack(side=LEFT)
20239  StopBodeEntry = Entry(Frange2, width=5, cursor='double_arrow')
20240  StopBodeEntry.bind('<Return>', onTextKey)
20241  StopBodeEntry.bind('<MouseWheel>', onStopBodeScroll)
20242  StopBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20243  StopBodeEntry.bind("<Button-5>", onTextScroll)
20244  StopBodeEntry.bind('<Key>', onTextKey)
20245  StopBodeEntry.pack(side=LEFT)
20246  StopBodeEntry.delete(0,"end")
20247  StopBodeEntry.insert(0,10000)
20248 
20249  sgrb1 = Radiobutton(frame2bp, text='None', variable=FSweepMode, value=0)
20250  sgrb1.pack(side=TOP)
20251  Frange4 = Frame( frame2bp )
20252  Frange4.pack(side=TOP)
20253  sgrb2 = Radiobutton(Frange4, text='CH-A', variable=FSweepMode, value=1)
20254  sgrb2.pack(side=LEFT)
20255  sgrb3 = Radiobutton(Frange4, text='CH-B', variable=FSweepMode, value=2)
20256  sgrb3.pack(side=LEFT)
20257  if MinigenScreenStatus.get() > 0:
20258  sgrb1 = Radiobutton(frame2bp, text='MinGen', variable=FSweepMode, value=3)
20259  sgrb1.pack(side=TOP)
20260  ffcb = Checkbutton(frame2bp, text='Sweep From File', variable=BDSweepFile, command=BDSweepFromFile)
20261  ffcb.pack(side=TOP)
20262  Frange3 = Frame( frame2bp )
20263  Frange3.pack(side=TOP)
20264  sweepsteplab = Label(Frange3, text="Sweep Steps")
20265  sweepsteplab.pack(side=LEFT)
20266  SweepStepBodeEntry = Entry(Frange3, width=5, cursor='double_arrow')
20267  SweepStepBodeEntry.bind('<Return>', onTextKey)
20268  SweepStepBodeEntry.bind('<MouseWheel>', onTextScroll)
20269  SweepStepBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20270  SweepStepBodeEntry.bind("<Button-5>", onTextScroll)
20271  SweepStepBodeEntry.bind('<Key>', onTextKey)
20272  SweepStepBodeEntry.pack(side=LEFT)
20273  SweepStepBodeEntry.delete(0,"end")
20274  SweepStepBodeEntry.insert(0,100)
20275 
20276  sgrb5 = Radiobutton(frame2bp, text='Single', variable=FSweepCont, value=0)
20277  sgrb5.pack(side=TOP)
20278  sgrb6 = Radiobutton(frame2bp, text='Continuous', variable=FSweepCont, value=1)
20279  sgrb6.pack(side=TOP)
20280  Plotsframe = Frame( frame2bp )
20281  Plotsframe.pack(side=TOP)
20282  nyquistplotbutton = Button(Plotsframe, text="Polar Plot", style="W9.TButton", command=MakeNyquistPlot)
20283  nyquistplotbutton.pack(side=LEFT)
20284  nicholsplotbutton = Button(Plotsframe, text="Rect Plot", style="W8.TButton", command=MakeNicPlot)
20285  nicholsplotbutton.pack(side=LEFT)
20286  bodismiss1button = Button(frame2bp, text="Dismiss", style="W8.TButton", command=DestroyBodeScreen)
20287  bodismiss1button.pack(side=TOP)
20288 
20289  ADI2 = Label(frame2bp, image=logo, anchor= "sw", compound="top") #, height=49, width=116
20290  ADI2.pack(side=TOP)
20291  if ShowBallonHelp > 0:
20292  sbode_tip = CreateToolTip(sbode, 'Stop acquiring data')
20293  rbode_tip = CreateToolTip(rbode, 'Start acquiring data')
20294  bd3_tip = CreateToolTip(bd3, 'Increase number of dB/Div')
20295  bd4_tip = CreateToolTip(bd4, 'Decrease number of dB/Div')
20296  bd5_tip = CreateToolTip(bd5, 'Increase Ref Level by 10 dB')
20297  bd6_tip = CreateToolTip(bd6, 'Decrease Ref Level by 10 dB')
20298  bd7_tip = CreateToolTip(bd7, 'Increase Ref Level by 1 dB')
20299  bd8_tip = CreateToolTip(bd8, 'Decrease Ref Level by 1 dB')
20300  bodismiss1button_tip = CreateToolTip(bodismiss1button, 'Dismiss Bode Plot window')
20301  if LocalLanguage != "English":
20302  BLoadConfig(LocalLanguage) # load local language configuration
20303 #
20304 def DestroyBodeScreen():
20305  global bodewindow, BodeScreenStatus, ca, FSweepMode
20306 
20307  BodeScreenStatus.set(0)
20308  FSweepMode.set(0)
20309  BodeDisp.set(0)
20310  BodeCheckBox()
20311  bodewindow.destroy()
20312  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
20313 #
20314 def FreqCaresize(event):
20315  global Freqca, GRWF, XOLF, GRHF, Y0TF, CANVASwidthF, CANVASheightF, FontSize
20316 
20317  CANVASwidthF = event.width - 4
20318  CANVASheightF = event.height - 4
20319  GRWF = CANVASwidthF - 10 - (2 * X0LF) # new grid width
20320  GRHF = CANVASheightF - int(10 * FontSize) # new grid height
20321  UpdateFreqAll()
20322 #
20323 # ================ Make spectrum sub window ==========================
20324 def MakeSpectrumWindow():
20325  global logo, SmoothCurvesSA, CutDC, SingleShotSA, FFTwindow, freqwindow, SmoothCurvesSA
20326  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMarker, FreqDisp, ShowAWGASA
20327  global ShowRA_VdB, ShowRA_P, ShowRB_VdB, ShowRB_P, ShowMathSA, SWRev, SingleShotSA, ShowAWGBSA
20328  global ShowRMath, FSweepMode, FSweepCont, Freqca, SpectrumScreenStatus, RevDate, AWGShowAdvanced
20329  global HScale, StopFreqEntry, StartFreqEntry, ShowFCur, ShowdBCur, FCursor, dBCursor
20330  global CANVASwidthF, GRWF, X0LF, CANVASheightF, GRHF, FontSize, PhCenFreqEntry, RelPhaseCenter
20331  global FrameRefief, BorderSize, LocalLanguage, SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry
20332  global sb_tip, rb_tip, bless_tip, bmore_tip, b3_tip, b4_tip, b5_tip, b6_tip, b7_tip, b8_tip, sadismiss1button_tip
20333  global SAMagdiv, SAVScale, SAvertmaxEntry, SAvertminEntry, SAVPSD
20334 
20335  if SpectrumScreenStatus.get() == 0:
20336  SpectrumScreenStatus.set(1)
20337  FreqDisp.set(1)
20338  FreqCheckBox()
20339  CANVASwidthF = GRWF + 10 + 2 * X0LF # The spectrum canvas width
20340  CANVASheightF = GRHF + int(10 * FontSize) # 80 The spectrum canvas height
20341  freqwindow = Toplevel()
20342  freqwindow.title("Spectrum Analyzer " + SWRev + RevDate)
20343  freqwindow.protocol("WM_DELETE_WINDOW", DestroySpectrumScreen)
20344  frame2fr = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
20345  frame2fr.pack(side=RIGHT, expand=NO, fill=BOTH)
20346 
20347  frame2f = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
20348  frame2f.pack(side=TOP, expand=YES, fill=BOTH)
20349 
20350  Freqca = Canvas(frame2f, width=CANVASwidthF, height=CANVASheightF, background=COLORcanvas, cursor='cross')
20351  Freqca.bind('<Configure>', FreqCaresize)
20352  Freqca.bind('<1>', onCanvasFreqLeftClick)
20353  Freqca.bind('<3>', onCanvasFreqRightClick)
20354  Freqca.bind("<Up>", onCanvasUpArrow)
20355  Freqca.bind("<Down>", onCanvasDownArrow)
20356  Freqca.bind("<Left>", onCanvasLeftArrow)
20357  Freqca.bind("<Right>", onCanvasRightArrow)
20358  Freqca.bind("<space>", onCanvasSpaceBar)
20359  Freqca.bind("1", onCanvasSAOne)
20360  Freqca.bind("2", onCanvasSATwo)
20361  Freqca.bind("3", onCanvasSAThree)
20362  Freqca.bind("4", onCanvasSAFour)
20363  Freqca.bind("5", onCanvasSAFive)
20364  Freqca.bind("6", onCanvasSASix)
20365  Freqca.bind("7", onCanvasSASeven)
20366  Freqca.bind("8", onCanvasSAEight)
20367  Freqca.bind("9", onCanvasSANine)
20368  Freqca.bind("0", onCanvasSAZero)
20369  Freqca.bind("a", onCanvasSAAverage)
20370  Freqca.bind("n", onCanvasSANormal)
20371  Freqca.bind("p", onCanvasSAPeak)
20372  Freqca.bind("r", onCanvasSAReset)
20373  Freqca.bind("f", onCanvasShowFcur)
20374  Freqca.bind("d", onCanvasShowdBcur)
20375  Freqca.bind("h", onCanvasShowPcur)
20376  Freqca.bind("s", onCanvasSASnap)
20377  Freqca.pack(side=TOP, expand=YES, fill=BOTH)
20378  # right side drop down menu buttons
20379  dropmenu = Frame( frame2fr )
20380  dropmenu.pack(side=TOP)
20381  # File menu
20382  SAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
20383  SAFilemenu.menu = Menu(SAFilemenu, tearoff = 0 )
20384  SAFilemenu["menu"] = SAFilemenu.menu
20385  SAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigSA)
20386  SAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigSA)
20387  SAFilemenu.menu.add_command(label="Run Script", command=RunScript)
20388  SAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenSA)
20389  SAFilemenu.menu.add_command(label="Save Data", command=STOREcsvfile)
20390  SAFilemenu.pack(side=LEFT, anchor=W)
20391  #
20392  SAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
20393  SAOptionmenu.menu = Menu(SAOptionmenu, tearoff = 0 )
20394  SAOptionmenu["menu"] = SAOptionmenu.menu
20395  SAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
20396  SAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
20397  SAOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesSA)
20398  SAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
20399  SAOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceSA)
20400  SAOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
20401  SAOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
20402  SAOptionmenu.pack(side=LEFT, anchor=W)
20403  #
20404  RUNframe = Frame( frame2fr )
20405  RUNframe.pack(side=TOP)
20406  sarb = Button(RUNframe, text="Run", style="Run.TButton", command=BStartSA)
20407  sarb.pack(side=LEFT)
20408  sasb = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopSA)
20409  sasb.pack(side=LEFT)
20410  #
20411  Modeframe = Frame( frame2fr )
20412  Modeframe.pack(side=TOP)
20413  Modemenu = Menubutton(Modeframe, text="Mode", style="W5.TButton")
20414  Modemenu.menu = Menu(Modemenu, tearoff = 0 )
20415  Modemenu["menu"] = Modemenu.menu
20416  Modemenu.menu.add_command(label="Normal mode [n]", command=BNormalmode)
20417  Modemenu.menu.add_command(label="Peak hold [p]", command=BPeakholdmode)
20418  Modemenu.menu.add_command(label="Average [a]", command=BAveragemode)
20419  Modemenu.menu.add_command(label="Reset Average [r]", command=BResetFreqAvg)
20420  Modemenu.menu.add_checkbutton(label='SingleShot', variable=SingleShotSA)
20421  Modemenu.pack(side=LEFT)
20422  #
20423  SAFFTwindmenu = Menubutton(Modeframe, text="FFTwindow", style="W11.TButton")
20424  SAFFTwindmenu.menu = Menu(SAFFTwindmenu, tearoff = 0 )
20425  SAFFTwindmenu["menu"] = SAFFTwindmenu.menu
20426  SAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
20427  SAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
20428  SAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
20429  SAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
20430  SAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
20431  SAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
20432  SAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
20433  SAFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
20434  SAFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
20435  SAFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
20436  SAFFTwindmenu.pack(side=LEFT)
20437  #
20438  SamplesMenu = Frame( frame2fr )
20439  SamplesMenu.pack(side=TOP)
20440  bless = Button(SamplesMenu, text="-Samples", style="W8.TButton", command=Bsamples1)
20441  bless.pack(side=LEFT)
20442  bmore = Button(SamplesMenu, text="+Samples", style="W8.TButton", command=Bsamples2)
20443  bmore.pack(side=LEFT)
20444  #
20445  # Show channels menu
20446  #
20447  MarkersMenu = Frame( frame2fr )
20448  MarkersMenu.pack(side=TOP)
20449  SAShowmenu = Menubutton(MarkersMenu, text="Curves", style="W7.TButton")
20450  SAShowmenu.menu = Menu(SAShowmenu, tearoff = 0 )
20451  SAShowmenu["menu"] = SAShowmenu.menu
20452  SAShowmenu.menu.add_command(label="-Show-", command=donothing)
20453  SAShowmenu.menu.add_command(label="All", command=BShowCurvesAllSA)
20454  SAShowmenu.menu.add_command(label="None", command=BShowCurvesNoneSA)
20455  SAShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowC1_VdB, command=UpdateFreqAll)
20456  SAShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowC2_VdB, command=UpdateFreqAll)
20457  SAShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowC1_P, command=UpdateFreqAll)
20458  SAShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowC2_P, command=UpdateFreqAll)
20459  SAShowmenu.menu.add_command(label="-Math-", command=donothing)
20460  SAShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathSA, value=0, command=UpdateFreqAll)
20461  SAShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathSA, value=1, command=UpdateFreqAll)
20462  SAShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathSA, value=2, command=UpdateFreqAll)
20463  if AWGShowAdvanced.get() > 0:
20464  SAShowmenu.menu.add_command(label="-AWG-", command=donothing)
20465  SAShowmenu.menu.add_checkbutton(label='AWG A', variable=ShowAWGASA, command=UpdateFreqAll)
20466  SAShowmenu.menu.add_checkbutton(label='AWG B', variable=ShowAWGBSA, command=UpdateFreqAll)
20467  SAShowmenu.menu.add_command(label="-Ref Trace-", command=donothing)
20468  SAShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowRA_VdB, command=UpdateFreqAll)
20469  SAShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowRB_VdB, command=UpdateFreqAll)
20470  SAShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowRA_P, command=UpdateFreqAll)
20471  SAShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowRB_P, command=UpdateFreqAll)
20472  SAShowmenu.menu.add_checkbutton(label='Ref Math', variable=ShowRMath, command=UpdateFreqAll)
20473  SAShowmenu.pack(side=LEFT)
20474  SACursormenu = Menubutton(MarkersMenu, text="Cursors", style="W7.TButton")
20475  SACursormenu.menu = Menu(SACursormenu, tearoff = 0 )
20476  SACursormenu["menu"] = SACursormenu.menu
20477  SACursormenu.menu.add_command(label="-Marker-", command=donothing)
20478  SACursormenu.menu.add_radiobutton(label='Markers Off', variable=ShowMarker, value=0, command=UpdateFreqAll)
20479  SACursormenu.menu.add_radiobutton(label='Markers [5]', variable=ShowMarker, value=1, command=UpdateFreqAll)
20480  SACursormenu.menu.add_radiobutton(label='Delta Markers', variable=ShowMarker, value=2, command=UpdateFreqAll)
20481  SACursormenu.menu.add_command(label="-Cursors-", command=donothing)
20482  SACursormenu.menu.add_radiobutton(label='Cursor Off', variable=ShowdBCur, value=0)
20483  SACursormenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowdBCur, value=1)
20484  #SACursormenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowdBCur, value=2)
20485  SACursormenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowFCur)
20486  SACursormenu.pack(side=LEFT)
20487  # HScale
20488  Frange1 = Frame( frame2fr )
20489  Frange1.pack(side=TOP)
20490  startfreqlab = Label(Frange1, text="Startfreq")
20491  startfreqlab.pack(side=LEFT)
20492  StartFreqEntry = Entry(Frange1, width=5, cursor='double_arrow')
20493  StartFreqEntry.bind('<Return>', onTextKey)
20494  StartFreqEntry.bind('<MouseWheel>', onTextScroll)
20495  StartFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20496  StartFreqEntry.bind("<Button-5>", onTextScroll)
20497  StartFreqEntry.bind('<Key>', onTextKey)
20498  StartFreqEntry.pack(side=LEFT)
20499  StartFreqEntry.delete(0,"end")
20500  StartFreqEntry.insert(0,10)
20501 
20502  Frange2 = Frame( frame2fr )
20503  Frange2.pack(side=TOP)
20504  stopfreqlab = Label(Frange2, text="Stopfreq")
20505  stopfreqlab.pack(side=LEFT)
20506  StopFreqEntry = Entry(Frange2, width=7, cursor='double_arrow')
20507  StopFreqEntry.bind('<Return>', onTextKey)
20508  StopFreqEntry.bind('<MouseWheel>', onStopfreqScroll)
20509  StopFreqEntry.bind("<Button-4>", onStopfreqScroll)# with Linux OS
20510  StopFreqEntry.bind("<Button-5>", onStopfreqScroll)
20511  StopFreqEntry.bind('<Key>', onTextKey)
20512  StopFreqEntry.pack(side=LEFT)
20513  StopFreqEntry.delete(0,"end")
20514  StopFreqEntry.insert(0,10000)
20515 
20516  HzScale = Frame( frame2fr )
20517  HzScale.pack(side=TOP)
20518  sarb1 = Radiobutton(HzScale, text="Lin F", variable=HScale, value=0, command=UpdateFreqTrace )
20519  sarb1.pack(side=LEFT)
20520  sarb2 = Radiobutton(HzScale, text="Log F", variable=HScale, value=1, command=UpdateFreqTrace )
20521  sarb2.pack(side=LEFT)
20522  #
20523  PhaseCenter = Frame( frame2fr )
20524  PhaseCenter.pack(side=TOP)
20525  PhCenlab = Label(PhaseCenter, text="Center Phase on")
20526  PhCenlab.pack(side=LEFT)
20527  PhCenFreqEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
20528  PhCenFreqEntry.bind('<Return>', onTextKey)
20529  PhCenFreqEntry.bind('<MouseWheel>', onTextScroll)
20530  PhCenFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20531  PhCenFreqEntry.bind("<Button-5>", onTextScroll)
20532  PhCenFreqEntry.bind('<Key>', onTextKey)
20533  PhCenFreqEntry.pack(side=LEFT)
20534  PhCenFreqEntry.delete(0,"end")
20535  PhCenFreqEntry.insert(0,RelPhaseCenter.get())
20536  #
20537  vertlabel = Label( frame2fr, text="Vertical Scale" )
20538  vertlabel.pack(side=TOP)
20539  savrb0 = Radiobutton(frame2fr, text="In dB", variable=SAVScale, value=0, command=UpdateFreqTrace )
20540  savrb0.pack(side=TOP)
20541  #
20542  DBrange = Frame( frame2fr )
20543  DBrange.pack(side=TOP)
20544  sab3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2)
20545  sab3.pack(side=LEFT)
20546  sab4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1)
20547  sab4.pack(side=LEFT)
20548 
20549  LVBrange = Frame( frame2fr )
20550  LVBrange.pack(side=TOP)
20551  sab5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4)
20552  sab5.pack(side=LEFT)
20553  sab6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3)
20554  sab6.pack(side=LEFT)
20555 
20556  LVSrange = Frame( frame2fr )
20557  LVSrange.pack(side=TOP)
20558  sab7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2)
20559  sab7.pack(side=LEFT)
20560  sab8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1)
20561  sab8.pack(side=LEFT)
20562  # Add RMS V controls
20563  vertscale = Frame( frame2fr )
20564  vertscale.pack(side=TOP)
20565  savlab1 = Label(vertscale, text="V RMS")
20566  savlab1.pack(side=LEFT)
20567  savrb1 = Radiobutton(vertscale, text="Lin", variable=SAVScale, value=1, command=UpdateFreqTrace )
20568  savrb1.pack(side=LEFT)
20569  savrb2 = Radiobutton(vertscale, text="Log", variable=SAVScale, value=2, command=UpdateFreqTrace )
20570  savrb2.pack(side=LEFT)
20571  sapsdcb = Checkbutton(frame2fr, text="PSD (sqrt Hz)", variable=SAVPSD)
20572  sapsdcb.pack(side=TOP)
20573  #
20574  vertmax = Frame( frame2fr )
20575  vertmax.pack(side=TOP)
20576  vertmaxlab = Label(vertmax, text="VRMS Max")
20577  vertmaxlab.pack(side=LEFT)
20578  SAvertmaxEntry = Spinbox(vertmax, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBlevel)
20579  SAvertmaxEntry.bind('<MouseWheel>', onSpinBoxScroll)
20580  SAvertmaxEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20581  SAvertmaxEntry.bind("<Button-5>", onSpinBoxScroll)
20582  SAvertmaxEntry.delete(0,"end")
20583  SAvertmaxEntry.insert(0,"1.0")
20584  SAvertmaxEntry.pack(side=LEFT)
20585 
20595  vertmin = Frame( frame2fr )
20596  vertmin.pack(side=TOP)
20597  vertminlab = Label(vertmin, text="VRMS Min")
20598  vertminlab.pack(side=LEFT)
20599  SAvertminEntry = Spinbox(vertmin, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBlevel)
20600  SAvertminEntry.bind('<MouseWheel>', onSpinBoxScroll)
20601  SAvertminEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20602  SAvertminEntry.bind("<Button-5>", onSpinBoxScroll)
20603  SAvertminEntry.pack(side=LEFT)
20604  SAvertminEntry.delete(0,"end")
20605  SAvertminEntry.insert(0,"100uV")
20606 
20616  sadismiss1button = Button(frame2fr, text="Dismiss", style="W8.TButton", command=DestroySpectrumScreen)
20617  sadismiss1button.pack(side=TOP)
20618 
20619  ADI2 = Label(frame2fr, image=logo, anchor= "sw", compound="top") #, height=49, width=116
20620  ADI2.pack(side=TOP)
20621  if ShowBallonHelp > 0:
20622  sb_tip = CreateToolTip(sasb, 'Stop acquiring data')
20623  rb_tip = CreateToolTip(sarb, 'Start acquiring data')
20624  bless_tip = CreateToolTip(bless, 'Decrease FFT samples')
20625  bmore_tip = CreateToolTip(bmore, 'Increase FFT samples')
20626  b3_tip = CreateToolTip(sab3, 'Increase number of dB/Div')
20627  b4_tip = CreateToolTip(sab4, 'Decrease number of dB/Div')
20628  b5_tip = CreateToolTip(sab5, 'Increase Ref Level by 10 dB')
20629  b6_tip = CreateToolTip(sab6, 'Decrease Ref Level by 10 dB')
20630  b7_tip = CreateToolTip(sab7, 'Increase Ref Level by 1 dB')
20631  b8_tip = CreateToolTip(sab8, 'Decrease Ref Level by 1 dB')
20632  sadismiss1button_tip = CreateToolTip(sadismiss1button, 'Dismiss Spectrum Analyzer window')
20633  if LocalLanguage != "English":
20634  BLoadConfig(LocalLanguage) # load local language configuration
20635 
20636 def DestroySpectrumScreen():
20637  global freqwindow, SpectrumScreenStatus, ca
20638 
20639  SpectrumScreenStatus.set(0)
20640  FreqDisp.set(0)
20641  FreqCheckBox()
20642  freqwindow.destroy()
20643  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
20644 #
20645 def XYcaresize(event):
20646  global XYca, GRWXY, XOLXY, GRHXY, Y0TXY, CANVASwidthXY, CANVASheightXY, FontSize
20647  global YminXY, YmaxXY, XminXY, XmaxXY
20648 
20649  XOLXY = FontSize * 7
20650  CANVASwidthXY = event.width - 4
20651  CANVASheightXY = event.height - 4
20652  GRWXY = CANVASwidthXY - (2*X0LXY) # 18 new grid width
20653  GRHXY = CANVASheightXY - int(10 * FontSize) # new grid height
20654  YminXY = Y0TXY # Minimum position of time grid (top)
20655  YmaxXY = Y0TXY + GRHXY # Maximum position of time grid (bottom)
20656  XminXY = X0LXY # Minimum position of time grid (left)
20657  XmaxXY = X0LXY + GRWXY # Maximum position of time grid (right)
20658  UpdateXYAll()
20659 #
20660 # ================ Make XY Plot sub window ==========================
20661 def MakeXYWindow():
20662  global logo, CANVASwidthXY, CANVASheightXY, Xsignal, EnableUserEntries
20663  global YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
20664  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
20665  global XYScreenStatus, MarkerXYScale, XYca, xywindow, RevDate, SWRev, XYDisp
20666  global CHAsbxy, CHBsbxy, CHAxylab, CHBxylab, CHAVPosEntryxy, CHBVPosEntryxy
20667  global CHAIsbxy, CHBIsbxy, CHAIPosEntryxy, CHBIPosEntryxy, ScreenXYrefresh
20668  global YminXY, Y0TXY, YmaxXY, GRHXY, XminXY, X0LXY, XmaxXY, X0LXY, GRWXY, CANVASwidthXY, CANVASheightXY
20669  global FrameRefief, BorderSize, LocalLanguage, User3Entry, User4Entry
20670  global math_tip, bsxy_tip, brxy_tip, snapbutton_tip, savebutton_tip, dismissxybutton_tip, CHAxylab_tip
20671  global CHBxylab_tip, CHAxyofflab_tip, CHBxyofflab_tip, CHAIxyofflab_tip, CHBIxyofflab_tip
20672 
20673  if XYScreenStatus.get() == 0:
20674  XYScreenStatus.set(1)
20675  XYDisp.set(1)
20676  XYCheckBox()
20677  YminXY = Y0TXY # Minimum position of XY grid (top)
20678  YmaxXY = Y0TXY + GRHXY # Maximum position of XY grid (bottom)
20679  XminXY = X0LXY # Minimum position of XY grid (left)
20680  XmaxXY = X0LXY + GRWXY # Maximum position of XY grid (right)
20681  CANVASwidthXY = GRWXY + (2*X0LXY) # The XY canvas width
20682  CANVASheightXY = GRHXY + 80 # The XY canvas height
20683  xywindow = Toplevel()
20684  xywindow.title("X-Y Plot " + SWRev + RevDate)
20685  xywindow.protocol("WM_DELETE_WINDOW", DestroyXYScreen)
20686  frame2xyr = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
20687  frame2xyr.pack(side=RIGHT, expand=NO, fill=BOTH)
20688 
20689  frame2xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
20690  frame2xy.pack(side=TOP, expand=YES, fill=BOTH)
20691 
20692  frame3xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
20693  frame3xy.pack(side=TOP, expand=NO, fill=BOTH)
20694 
20695  frame4xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
20696  frame4xy.pack(side=TOP, expand=NO, fill=BOTH)
20697 
20698  XYca = Canvas(frame2xy, width=CANVASwidthXY, height=CANVASheightXY, background=COLORcanvas, cursor='cross')
20699  XYca.bind('<Configure>', XYcaresize)
20700  XYca.bind('<1>', onCanvasXYLeftClick)
20701  XYca.bind('<3>', onCanvasXYRightClick)
20702  XYca.bind("<Motion>",onCanvasMouse_xy)
20703  XYca.bind('<MouseWheel>', onCanvasXYScrollClick)
20704  XYca.bind("<Button-4>", onCanvasXYScrollClick)# with Linux OS
20705  XYca.bind("<Button-5>", onCanvasXYScrollClick)
20706  XYca.bind("<Up>", onCanvasUpArrow)
20707  XYca.bind("<Down>", onCanvasDownArrow)
20708  XYca.bind("<Left>", onCanvasLeftArrow)
20709  XYca.bind("<Right>", onCanvasRightArrow)
20710  XYca.bind("<space>", onCanvasSpaceBar)
20711  XYca.bind("a", onCanvasAverage)
20712  XYca.pack(side=TOP, fill=BOTH, expand=YES)
20713  #
20714  RUNframe = Frame( frame2xyr )
20715  RUNframe.pack(side=TOP)
20716  rbxy = Button(RUNframe, text="Run", style="Run.TButton", command=BStart)
20717  rbxy.pack(side=LEFT)
20718  sbxy = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStop)
20719  sbxy.pack(side=LEFT)
20720  # Open Math trace menu
20721  mathbt = Button(frame2xyr, text="Math", style="W5.TButton", command = NewEnterMathControls)
20722  mathbt.pack(side=TOP) #, anchor=W)
20723  # Disply mode menu
20724  # X - Y mode signal select
20725  AxisLabX = Label(frame2xyr, text ="-X Axis-", style="A10R1.TLabelframe.Label")
20726  AxisLabX.pack(side=TOP)
20727  chaxmenu = Frame( frame2xyr )
20728  chaxmenu.pack(side=TOP)
20729  rbx2 = Radiobutton(chaxmenu, text='CA-V', variable=Xsignal, value=1, command=UpdateXYTrace)
20730  rbx2.pack(side=LEFT, anchor=W)
20731  rbx3 = Radiobutton(chaxmenu, text='CA-I', variable=Xsignal, value=2, command=UpdateXYTrace)
20732  rbx3.pack(side=LEFT, anchor=W)
20733  chbxmenu = Frame( frame2xyr )
20734  chbxmenu.pack(side=TOP)
20735  rbx4 = Radiobutton(chbxmenu, text='CB-V', variable=Xsignal, value=3, command=UpdateXYTrace)
20736  rbx4.pack(side=LEFT, anchor=W)
20737  rbx5 = Radiobutton(chbxmenu, text='CB-I', variable=Xsignal, value=4, command=UpdateXYTrace)
20738  rbx5.pack(side=LEFT, anchor=W)
20739  rbx7 = Radiobutton(frame2xyr, text='Histogram CA-V', variable=Xsignal, value=6, command=BHistAsPercent)
20740  rbx7.pack(side=TOP)
20741  rbx8 = Radiobutton(frame2xyr, text='Histogram CB-V', variable=Xsignal, value=7, command=BHistAsPercent)
20742  rbx8.pack(side=TOP)
20743  rbx6 = Radiobutton(frame2xyr, text='Math', variable=Xsignal, value=5, command=UpdateXYTrace)
20744  rbx6.pack(side=TOP)
20745  #
20746  AxisLabY = Label(frame2xyr, text ="-Y Axis-", style="A10R2.TLabelframe.Label")
20747  AxisLabY.pack(side=TOP)
20748  chaymenu = Frame( frame2xyr )
20749  chaymenu.pack(side=TOP)
20750  rby2 = Checkbutton(chaymenu, text='CA-V', variable=YsignalVA, command=UpdateXYTrace)
20751  rby2.pack(side=LEFT, anchor=W)
20752  rby3 = Checkbutton(chaymenu, text='CA-I', variable=YsignalIA, command=UpdateXYTrace)
20753  rby3.pack(side=LEFT, anchor=W)
20754  chbymenu = Frame( frame2xyr )
20755  chbymenu.pack(side=TOP)
20756  rby4 = Checkbutton(chbymenu, text='CB-V', variable=YsignalVB, command=UpdateXYTrace)
20757  rby4.pack(side=LEFT, anchor=W)
20758  rby5 = Checkbutton(chbymenu, text='CB-I', variable=YsignalIB, command=UpdateXYTrace)
20759  rby5.pack(side=LEFT, anchor=W)
20760  rby7 = Checkbutton(frame2xyr, text='Math', variable=YsignalM, command=UpdateXYTrace)
20761  rby7.pack(side=TOP)
20762  mymenu = Frame( frame2xyr )
20763  mymenu.pack(side=TOP)
20764  rby7 = Checkbutton(mymenu, text='Math-X', variable=YsignalMX, command=UpdateXYTrace)
20765  rby7.pack(side=LEFT, anchor=W)
20766  rby8 = Checkbutton(mymenu, text='Math-Y', variable=YsignalMY, command=UpdateXYTrace)
20767  rby8.pack(side=LEFT, anchor=W)
20768  # show cursor menu buttons
20769  cursormenu = Frame( frame2xyr )
20770  cursormenu.pack(side=TOP)
20771  cb1 = Checkbutton(cursormenu, text='X-Cur', variable=ShowXCur)
20772  cb1.pack(side=LEFT, anchor=W)
20773  cb2 = Checkbutton(cursormenu, text='Y-Cur', variable=ShowYCur)
20774  cb2.pack(side=LEFT, anchor=W)
20775  cb4 = Checkbutton(frame2xyr, text='Persistance', variable=ScreenXYrefresh, command=UpdateXYTrace)
20776  cb4.pack(side=TOP)
20777  #
20778  # Reference trace menu
20779  XYrefmenu = Menubutton(frame2xyr, text="Ref Traces", style="W11.TButton")
20780  XYrefmenu.menu = Menu(XYrefmenu, tearoff = 0 )
20781  XYrefmenu["menu"] = XYrefmenu.menu
20782  XYrefmenu.menu.add_command(label="Save SnapShot", command=BSnapShotXY)
20783  XYrefmenu.menu.add_checkbutton(label="CA-V", variable=XYRefAV, command=UpdateXYTrace)
20784  XYrefmenu.menu.add_checkbutton(label="CA-I", variable=XYRefAI, command=UpdateXYTrace)
20785  XYrefmenu.menu.add_checkbutton(label="CB-V", variable=XYRefBV, command=UpdateXYTrace)
20786  XYrefmenu.menu.add_checkbutton(label="CB-I", variable=XYRefBI, command=UpdateXYTrace)
20787  XYrefmenu.menu.add_checkbutton(label="Math", variable=XYRefM, command=UpdateXYTrace)
20788  XYrefmenu.menu.add_checkbutton(label="Math-X", variable=XYRefMX, command=UpdateXYTrace)
20789  XYrefmenu.menu.add_checkbutton(label="Math-Y", variable=XYRefMY, command=UpdateXYTrace)
20790  XYrefmenu.pack(side=TOP) # , anchor=W)
20791 
20793  dismissxybutton = Button(frame2xyr, style="W7.TButton", text="Dismiss", command=DestroyXYScreen)
20794  dismissxybutton.pack(side=TOP)
20795  # Add a pair of user entry wigets
20796  if EnableUserEntries > 0:
20797  UserEnt = Frame( frame2xyr )
20798  UserEnt.pack(side=TOP)
20799  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
20800  userentlab.pack(side=LEFT,fill=X)
20801  User3Entry = Entry(UserEnt, width=5, cursor='double_arrow')
20802  User3Entry.bind('<Return>', onTextKey)
20803  User3Entry.bind('<MouseWheel>', onTextScroll)
20804  User3Entry.bind("<Button-4>", onTextScroll)# with Linux OS
20805  User3Entry.bind("<Button-5>", onTextScroll)
20806  User3Entry.bind('<Key>', onTextKey)
20807  User3Entry.pack(side=LEFT)
20808  User3Entry.delete(0,"end")
20809  User3Entry.insert(0,0.0)
20810  User4Entry = Entry(UserEnt, width=5, cursor='double_arrow')
20811  User4Entry.bind('<Return>', onTextKey)
20812  User4Entry.bind('<MouseWheel>', onTextScroll)
20813  User4Entry.bind("<Button-4>", onTextScroll)# with Linux OS
20814  User4Entry.bind("<Button-5>", onTextScroll)
20815  User4Entry.bind('<Key>', onTextKey)
20816  User4Entry.pack(side=LEFT)
20817  User4Entry.delete(0,"end")
20818  User4Entry.insert(0,0.0)
20819  #
20820  ADI1xy = Label(frame2xyr, image=logo, anchor= "sw", compound="top") # , height=49, width=116
20821  ADI1xy.pack(side=TOP)
20822  # Bottom Buttons
20823  MarkerXYScale = IntVar(0)
20824  MarkerXYScale.set(1)
20825  # Voltage channel A
20826  CHAsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHvpdiv)
20827  CHAsbxy.bind('<MouseWheel>', onSpinBoxScroll)
20828  CHAsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20829  CHAsbxy.bind("<Button-5>", onSpinBoxScroll)
20830  CHAsbxy.pack(side=LEFT)
20831  CHAsbxy.delete(0,"end")
20832  CHAsbxy.insert(0,0.5)
20833  CHAxylab = Button(frame3xy, text="CA V/Div", style="Rtrace1.TButton", command=SetXYScaleA)
20834  CHAxylab.pack(side=LEFT)
20835 
20836  CHAVPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
20837  CHAVPosEntryxy.bind('<Return>', onTextKey)
20838  CHAVPosEntryxy.bind('<MouseWheel>', onTextScroll)
20839  CHAVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
20840  CHAVPosEntryxy.bind("<Button-5>", onTextScroll)
20841  CHAVPosEntryxy.bind('<Key>', onTextKey)
20842  CHAVPosEntryxy.pack(side=LEFT)
20843  CHAVPosEntryxy.delete(0,"end")
20844  CHAVPosEntryxy.insert(0,2.5)
20845  CHAofflabxy = Button(frame3xy, text="CA V Pos", style="Rtrace1.TButton", command=SetXYVAPoss)
20846  CHAofflabxy.pack(side=LEFT)
20847  # Current channel A
20848  CHAIsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHipdiv)
20849  CHAIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
20850  CHAIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20851  CHAIsbxy.bind("<Button-5>", onSpinBoxScroll)
20852  CHAIsbxy.pack(side=LEFT)
20853  CHAIsbxy.delete(0,"end")
20854  CHAIsbxy.insert(0,50.0)
20855  CHAIlabxy = Label(frame3xy, text="CA mA/Div", style="Strace3.TButton")
20856  CHAIlabxy.pack(side=LEFT)
20857 
20858  CHAIPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
20859  CHAIPosEntryxy.bind('<Return>', onTextKey)
20860  CHAIPosEntryxy.bind('<MouseWheel>', onTextScroll)
20861  CHAIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
20862  CHAIPosEntryxy.bind("<Button-5>", onTextScroll)
20863  CHAIPosEntryxy.bind('<Key>', onTextKey)
20864  CHAIPosEntryxy.pack(side=LEFT)
20865  CHAIPosEntryxy.delete(0,"end")
20866  CHAIPosEntryxy.insert(0,0.0)
20867  CHAIofflabxy = Button(frame3xy, text="CA I Pos", style="Rtrace3.TButton", command=SetXYIAPoss)
20868  CHAIofflabxy.pack(side=LEFT)
20869  # Voltage channel B
20870  CHBsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHvpdiv)
20871  CHBsbxy.bind('<MouseWheel>', onSpinBoxScroll)
20872  CHBsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20873  CHBsbxy.bind("<Button-5>", onSpinBoxScroll)
20874  CHBsbxy.pack(side=LEFT)
20875  CHBsbxy.delete(0,"end")
20876  CHBsbxy.insert(0,0.5)
20877  #
20878  CHBxylab = Button(frame4xy, text="CB V/Div", style="Strace2.TButton", command=SetXYScaleB)
20879  CHBxylab.pack(side=LEFT)
20880 
20881  CHBVPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
20882  CHBVPosEntryxy.bind('<Return>', onTextKey)
20883  CHBVPosEntryxy.bind('<MouseWheel>', onTextScroll)
20884  CHBVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
20885  CHBVPosEntryxy.bind("<Button-5>", onTextScroll)
20886  CHBVPosEntryxy.bind('<Key>', onTextKey)
20887  CHBVPosEntryxy.pack(side=LEFT)
20888  CHBVPosEntryxy.delete(0,"end")
20889  CHBVPosEntryxy.insert(0,2.5)
20890  CHBofflabxy = Button(frame4xy, text="CB V Pos", style="Rtrace2.TButton", command=SetXYVBPoss)
20891  CHBofflabxy.pack(side=LEFT)
20892  # Current channel B
20893  CHBIsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHipdiv) #
20894  CHBIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
20895  CHBIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20896  CHBIsbxy.bind("<Button-5>", onSpinBoxScroll)
20897  CHBIsbxy.pack(side=LEFT)
20898  CHBIsbxy.delete(0,"end")
20899  CHBIsbxy.insert(0,50.0)
20900  CHBIlabxy = Label(frame4xy, text="CB mA/Div", style="Strace4.TButton")
20901  CHBIlabxy.pack(side=LEFT)
20902 
20903  CHBIPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
20904  CHBIPosEntryxy.bind('<Return>', onTextKey)
20905  CHBIPosEntryxy.bind('<MouseWheel>', onTextScroll)
20906  CHBIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
20907  CHBIPosEntryxy.bind("<Button-5>", onTextScroll)
20908  CHBIPosEntryxy.bind('<Key>', onTextKey)
20909  CHBIPosEntryxy.pack(side=LEFT)
20910  CHBIPosEntryxy.delete(0,"end")
20911  CHBIPosEntryxy.insert(0,0.0)
20912  CHBIofflabxy = Button(frame4xy, text="CB I Pos", style="Rtrace4.TButton", command=SetXYIBPoss)
20913  CHBIofflabxy.pack(side=LEFT)
20914  #
20915  if ShowBallonHelp > 0:
20916  #xb1_tip = CreateToolTip(xb1, 'Enter formula for X axis Math trace')
20917  #xb2_tip = CreateToolTip(xb2, 'Enter which axis controls to use for X axis Math trace')
20918  #yb1_tip = CreateToolTip(yb1, 'Enter formula for Y axis Math trace')
20919  #yb2_tip = CreateToolTip(yb2, 'Enter which axis controls to use for Y axis Math trace')
20920  math_tip = CreateToolTip(mathbt, 'Open Math window')
20921  bsxy_tip = CreateToolTip(sbxy, 'Stop acquiring data')
20922  brxy_tip = CreateToolTip(rbxy, 'Start acquiring data')
20923  #snapbutton_tip = CreateToolTip(snapbutton, 'Take snap shot of current trace')
20924  #savebutton_tip = CreateToolTip(savebutton, 'Save current trace to EPS file')
20925  dismissxybutton_tip = CreateToolTip(dismissxybutton, 'Diamiss X-Y plot window')
20926  CHAxylab_tip = CreateToolTip(CHAxylab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
20927  CHBxylab_tip = CreateToolTip(CHBxylab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
20928  CHAxyofflab_tip = CreateToolTip(CHAofflabxy, 'Set CHA-V position to DC average of signal')
20929  CHBxyofflab_tip = CreateToolTip(CHBofflabxy, 'Set CHB-V position to DC average of signal')
20930  CHAIxyofflab_tip = CreateToolTip(CHAIofflabxy, 'Set CHA-I position to DC average of signal')
20931  CHBIxyofflab_tip = CreateToolTip(CHBIofflabxy, 'Set CHB-I position to DC average of signal')
20932  if LocalLanguage != "English":
20933  BLoadConfig(LocalLanguage)
20934 
20935 def DestroyXYScreen():
20936  global xywindow, XYScreenStatus, ca, XYDisp
20937 
20938  XYScreenStatus.set(0)
20939  XYDisp.set(0)
20940  XYCheckBox()
20941  xywindow.destroy()
20942  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
20943 #
20944 # Optional Calibration procedure routine
20945 #
20946 def SelfCalibration():
20947  global DevID, devx, CHA, CHB, RevDate, OnBoardRes, AD584act, FWRevOne
20948  global discontloop, contloop, session, AWGSync, SWRev
20949  # global OnBoardResAgnd, OnBoardResA25, OnBoardResBgnd, OnBoardResB25
20950  # setup cal results window
20951  if FWRevOne < 2.06: # Check firmware revision level > 2.06
20952  showwarning("WARNING","Out of date Firmware Revision!")
20953  return
20954  calwindow = Toplevel()
20955  calwindow.title("ALM1000 Calibration tool " + SWRev + RevDate)
20956  # display wigets
20957  SCallab = Label(calwindow, text="Channel Gain / Offset calibration")
20958  SCallab.grid(row=0, column=0, columnspan=2, sticky=W)
20959  labelA0 = Label(calwindow, style="A12B.TLabel")
20960  labelA0.grid(row=1, column=0, columnspan=2, sticky=W)
20961  labelA0.config(text = "CA gnd Volts")
20962  labelAMax = Label(calwindow, style="A12B.TLabel")
20963  labelAMax.grid(row=2, column=0, columnspan=2, sticky=W)
20964  labelAMax.config(text = "CA 584 Volts")
20965  labelAMin = Label(calwindow, style="A12B.TLabel")
20966  labelAMin.grid(row=3, column=0, columnspan=2, sticky=W)
20967  labelAMin.config(text = "CA 5V Src I ")
20968  labelB0 = Label(calwindow, style="A12B.TLabel")
20969  labelB0.grid(row=4, column=0, columnspan=2, sticky=W)
20970  labelB0.config(text = "CA gnd Volts")
20971  labelBMax = Label(calwindow, style="A12B.TLabel")
20972  labelBMax.grid(row=5, column=0, columnspan=2, sticky=W)
20973  labelBMax.config(text = "CB 584 Volts")
20974  labelBMin = Label(calwindow, style="A12B.TLabel")
20975  labelBMin.grid(row=6, column=0, columnspan=2, sticky=W)
20976  labelBMin.config(text = "CB 5V Src I ")
20977  labelAB = Label(calwindow, style="A12B.TLabel")
20978  labelAB.grid(row=7, column=0, columnspan=2, sticky=W)
20979  labelAB.config(text = "CA 0V Src I")
20980  labelBA = Label(calwindow, style="A12B.TLabel")
20981  labelBA.grid(row=8, column=0, columnspan=2, sticky=W)
20982  labelBA.config(text = "CA 0V Src I")
20983  labelSIA0 = Label(calwindow, style="A12B.TLabel")
20984  labelSIA0.grid(row=9, column=0, columnspan=2, sticky=W)
20985  labelSIA0.config(text = "CA 2.5 Src 0 I")
20986  labelSIA = Label(calwindow, style="A12B.TLabel")
20987  labelSIA.grid(row=10, column=0, columnspan=2, sticky=W)
20988  labelSIA.config(text = "CA 50 Src 100 ")
20989  labelSIAN = Label(calwindow, style="A12B.TLabel")
20990  labelSIAN.grid(row=11, column=0, columnspan=2, sticky=W)
20991  labelSIAN.config(text = "CA 50 Src -45")
20992  labelSIB0 = Label(calwindow, style="A12B.TLabel")
20993  labelSIB0.grid(row=12, column=0, columnspan=2, sticky=W)
20994  labelSIB0.config(text = "CB 2.5 Src 0 I")
20995  labelSIB = Label(calwindow, style="A12B.TLabel")
20996  labelSIB.grid(row=13, column=0, columnspan=2, sticky=W)
20997  labelSIB.config(text = "CB 50 Src 100 ")
20998  labelSIBN = Label(calwindow, style="A12B.TLabel")
20999  labelSIBN.grid(row=14, column=0, columnspan=2, sticky=W)
21000  labelSIBN.config(text = "CB 50 Src -45")
21001  # set to default mux and dac settings
21002  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
21003  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
21004  AWGSync.set(1)
21005  BAWGSync()
21006  if session.continuous:
21007  print( "ending session")
21008  session.end()
21009  # Setup ADALM1000
21010  if askyesno("Reset Calibration", "Do You Need To Reset Default Calibration?", parent=calwindow):
21011  #print(devx.calibration)
21012  try:
21013  devx.write_calibration("calib_default.txt")
21014  #print "wrote calib_default.txt"
21015  except:
21016  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Default Cal File", "*.txt")], parent=calwindow)
21017  devx.write_calibration(filename)
21018  #print(devx.calibration)
21019  #
21020  devidstr = DevID[17:31]
21021  filename = "calib" + devidstr + ".txt"
21022  if os.path.isfile(filename):
21023  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?", parent=calwindow):
21024  devx.write_calibration(filename)
21025  #print "wrote old ", filename
21026  calwindow.destroy()
21027  return
21028  else:
21029  if askyesno("Continue?", "Continure with self calibration?", parent=calwindow):
21030  donothing()
21031  else:
21032  calwindow.destroy()
21033  return
21034  #
21035  CalFile = open(filename, "w")
21036  #
21037  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
21038  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
21039  devx.ctrl_transfer( 0x40, 0x50, 34, 0, 0, 0, 100) # close voltage sense loop just in case
21040  devx.ctrl_transfer( 0x40, 0x50, 39, 0, 0, 0, 100) # close voltage sense loop just in case
21041  ADsignal1 = [] # Ain signal array channel
21042  ADsignal1 = devx.get_samples(1010)
21043  # Pause whie user connects external voltage reference AD584
21044  BadData = 1
21045  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
21046  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
21047  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
21048  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21049  RequestVRef = askstring("External Reference", "Enter External Reference Voltage", initialvalue=AD584act, parent=root)
21050  try:
21051  AD584act = float(RequestVRef)*1.0
21052  except:
21053  AD584act = 3.3
21054  showinfo("CONNECT","Connect External Voltage to both CHA and CHB inputs.", parent=calwindow)
21055  while (BadData): # loop till good reading
21056  # Get A and B AD584 data
21057  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
21058  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
21059  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21060  CHA584Raw = CHB584Raw = 0.0 # initalize measurment variable
21061  # get_samples returns a list of values for voltage [0] and current [1]
21062  for index in range(1000): # calculate average
21063  CHA584Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21064  CHB584Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21065 
21066  CHA584Raw = CHA584Raw / 1000.0 # calculate average
21067  CHB584Raw = CHB584Raw / 1000.0 # calculate average
21068  VString = "Extern A Volts " + ' {0:.4f} '.format(CHA584Raw) # format with 4 decimal places
21069  labelAMax.config(text = VString) # change displayed value
21070  VString = "Extern B Volts " + ' {0:.4f} '.format(CHB584Raw) # format with 4 decimal places
21071  labelBMax.config(text = VString) # change displayed value
21072  Lower = AD584act - 0.3
21073  Upper = AD584act + 0.3
21074  if CHA584Raw < Lower or CHA584Raw > Upper or CHB584Raw < Lower or CHB584Raw > Upper:
21075  if askyesno("CONNECT","Did not get good data from Ref V check connections!\n Abort(Y) or Try again(N)", parent=calwindow):
21076  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
21077  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
21078  contloop = 0
21079  discontloop = 1
21080  calwindow.destroy()
21081  return
21082  else:
21083  BadData = 0
21084  #
21085  showinfo("DISCONNECT","Disconnect everything from CHA and CHB pins.", parent=calwindow)
21086  CHAGndRaw = CHBGndRaw = CHAI0gRaw = CHBI0gRaw = 0.0 # initalize measurment variable
21087  # Get A GND and B GND data
21088  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
21089  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
21090  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
21091  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
21092  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
21093  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
21094  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21095  # get_samples returns a list of values for voltage [0] and current [1]
21096  for index in range(1000): # calculate average
21097  CHAGndRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21098  CHBGndRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21099  CHAI0gRaw += ADsignal1[index+10][0][1] # Sum for average CA current
21100  CHBI0gRaw += ADsignal1[index+10][1][1] # Sum for average CB current
21101 
21102  CHAGndRaw = CHAGndRaw / 1000.0 # calculate average
21103  CHAI0gRaw = CHAI0gRaw / 1000.0
21104  CHBGndRaw = CHBGndRaw / 1000.0 # calculate average
21105  CHBI0gRaw = CHBI0gRaw / 1000.0
21106  VString = "CA gnd Volts " + ' {0:.4f} '.format(CHAGndRaw) # format with 4 decimal places
21107  labelA0.config(text = VString) # change displayed value
21108  VString = "CB gnd Volts " + ' {0:.4f} '.format(CHBGndRaw) # format with 4 decimal places
21109  labelB0.config(text = VString) # change displayed value
21110  CHA2p5Raw = CHB2p5Raw = CHAI02p5Raw = CHBI02p5Raw = 0.0 # initalize measurment variable
21111  # Get A and B data for internal 2.5 rail
21112  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
21113  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
21114  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
21115  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
21116  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
21117  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21118  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21119  # get_samples returns a list of values for voltage [0] and current [1]
21120  for index in range(1000): # calculate average
21121  CHA2p5Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21122  CHB2p5Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21123  CHAI02p5Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21124  CHBI02p5Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21125 
21126  CHA2p5Raw = CHA2p5Raw / 1000.0 # calculate average
21127  CHAI02p5Raw = CHAI02p5Raw / 1000.0
21128  CHB2p5Raw = CHB2p5Raw / 1000.0 # calculate average
21129  CHBI02p5Raw = CHBI02p5Raw / 1000.0
21130  # Get A force 0V and B force 0V data
21131  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
21132  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
21133  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
21134  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21135  CHA.mode = Mode.SVMI
21136  CHA.constant(0.0)
21137  CHB.mode = Mode.SVMI
21138  CHB.constant(0.0)
21139  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21140  CHAF0vRaw = CHBF0vRaw = CHAI0F0Raw = CHBI0F0Raw = 0.0 # initalize measurment variable
21141  # get_samples returns a list of values for voltage [0] and current [1]
21142  for index in range(1000): # calculate average
21143  CHAF0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21144  CHBF0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21145  CHAI0F0Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21146  CHBI0F0Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21147 
21148  CHAF0vRaw = CHAF0vRaw / 1000.0 # calculate average
21149  CHAI0F0Raw = CHAI0F0Raw / 1000.0
21150  CHBF0vRaw = CHBF0vRaw / 1000.0 # calculate average
21151  CHBI0F0Raw = CHBI0F0Raw / 1000.0
21152  # Get A force 2.5V and B force 2.5V data
21153  CHA.mode = Mode.SVMI
21154  CHA.constant(4.5)
21155  CHB.mode = Mode.SVMI
21156  CHB.constant(4.5)
21157  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21158  CHAF25vRaw = CHAI0F25Raw = CHBF25vRaw = CHBI0F25Raw = 0.0 # initalize measurment variable
21159  # get_samples returns a list of values for voltage [0] and current [1]
21160  for index in range(1000): # calculate average
21161  CHAF25vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21162  CHBF25vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21163  CHAI0F25Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21164  CHBI0F25Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21165 
21166  CHAF25vRaw = CHAF25vRaw / 1000.0 # calculate average
21167  CHAI0F25Raw = CHAI0F25Raw / 1000.0
21168  CHBF25vRaw = CHBF25vRaw / 1000.0 # calculate average
21169  CHBI0F25Raw = CHBI0F25Raw / 1000.0
21170  #
21171  # Get A and B measure current data for int 50 res to gnd at 5V
21172  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
21173  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set CHA GND switch to closed
21174  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
21175  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
21176  CHA.mode = Mode.SVMI
21177  CHA.constant(5.0)
21178  CHB.mode = Mode.SVMI
21179  CHB.constant(5.0)
21180  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21181  CHASr5vRaw = CHAISr5vRaw = CHBSr5vRaw = CHBISr5vRaw = 0.0 # initalize measurment variable
21182  for index in range(1000): # calculate average
21183  CHASr5vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21184  CHBSr5vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21185  CHAISr5vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
21186  CHBISr5vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
21187 
21188  CHASr5vRaw = CHASr5vRaw / 1000.0 # calculate average
21189  CHAISr5vRaw = CHAISr5vRaw / 1000.0
21190  CHBSr5vRaw = CHBSr5vRaw / 1000.0 # calculate average
21191  CHBISr5vRaw = CHBISr5vRaw / 1000.0
21192  VString = "CA 5V Src I " + ' {0:.4f} '.format(CHAISr5vRaw) # format with 4 decimal places
21193  labelAMin.config(text = VString) # change displayed value
21194  VString = "CB 5V Src I " + ' {0:.4f} '.format(CHBISr5vRaw) # format with 4 decimal places
21195  labelBMin.config(text = VString) # change displayed value
21196  # Get A and B measure current data for int 50 res to 2.5 V at 0V
21197  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
21198  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
21199  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
21200  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21201  CHA.mode = Mode.SVMI
21202  CHA.constant(0.001)
21203  CHB.mode = Mode.SVMI
21204  CHB.constant(0.001)
21205  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21206  CHASr0vRaw = CHAISr0vRaw = CHBSr0vRaw = CHBISr0vRaw = 0.0 # initalize measurment variable
21207  for index in range(1000): # calculate average
21208  CHASr0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21209  CHBSr0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21210  CHAISr0vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
21211  CHBISr0vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
21212 
21213  CHASr0vRaw = CHASr0vRaw / 1000.0 # calculate average
21214  CHAISr0vRaw = CHAISr0vRaw / 1000.0
21215  CHBSr0vRaw = CHBSr0vRaw / 1000.0 # calculate average
21216  CHBISr0vRaw = CHBISr0vRaw / 1000.0
21217  VString = "CA 0V Src I " + ' {0:.4f} '.format(CHAISr0vRaw) # format with 4 decimal places
21218  labelAB.config(text = VString) # change displayed value
21219  VString = "CB 0V Src I " + ' {0:.4f} '.format(CHBISr0vRaw) # format with 4 decimal places
21220  labelBA.config(text = VString) # change displayed value
21221 
21222  # Get A and B force 0.0 current data for int 50 res to 2.5 rail
21223  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
21224  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
21225  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
21226  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21227  CHA.mode = Mode.SIMV
21228  CHA.constant(0.0)
21229  CHB.mode = Mode.SIMV
21230  CHB.constant(0.0)
21231  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21232  CHAVSr0iRaw = CHAISr0iRaw = CHBVSr0iRaw = CHBISr0iRaw = 0.0 # initalize measurment variable
21233  for index in range(1000): # calculate average
21234  CHAVSr0iRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21235  CHBVSr0iRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21236  CHAISr0iRaw += ADsignal1[index+10][0][1] # Sum for average CA current
21237  CHBISr0iRaw += ADsignal1[index+10][1][1] # Sum for average CB current
21238 
21239  CHAVSr0iRaw = CHAVSr0iRaw / 1000.0 # calculate average
21240  CHAISr0iRaw = CHAISr0iRaw / 1000.0
21241  CHBVSr0iRaw = CHBVSr0iRaw / 1000.0 # calculate average
21242  CHBISr0iRaw = CHBISr0iRaw / 1000.0
21243  VString = "CA 2.5 Src 0 I" + ' {0:.4f} '.format(CHAISr0iRaw) # format with 4 decimal places
21244  labelSIA0.config(text = VString) # change displayed value
21245  VString = "CB 2.5 Src 0 I" + ' {0:.4f} '.format(CHBISr0iRaw) # format with 4 decimal places
21246  labelSIB0.config(text = VString) # change displayed value
21247  #
21248  # Get A and B force +0.45 current data for int 50 res to 2.5 V rail
21249  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
21250  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
21251  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
21252  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21253  CHA.mode = Mode.SIMV
21254  CHA.constant(0.045)
21255  CHB.mode = Mode.SIMV
21256  CHB.constant(0.045)
21257  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21258  CHAVSr100Raw = CHAISr100Raw = CHBVSr100Raw = CHBISr100Raw = 0.0 # initalize measurment variable
21259  for index in range(1000): # calculate average
21260  CHAVSr100Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21261  CHBVSr100Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21262  CHAISr100Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21263  CHBISr100Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21264 
21265  CHAVSr100Raw = CHAVSr100Raw / 1000.0 # calculate average
21266  CHAISr100Raw = CHAISr100Raw / 1000.0
21267  CHBVSr100Raw = CHBVSr100Raw / 1000.0 # calculate average
21268  CHBISr100Raw = CHBISr100Raw / 1000.0
21269  VString = "CA 50 Src +45 " + ' {0:.4f} '.format(CHAVSr100Raw) # format with 4 decimal places
21270  labelSIA.config(text = VString) # change displayed value
21271  VString = "CB 50 Src +45 " + ' {0:.4f} '.format(CHBVSr100Raw) # format with 4 decimal places
21272  labelSIB.config(text = VString) # change displayed value
21273  #
21274  # Get A and B force -0.045 current data for int 50 res to 2.5 V rail
21275  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
21276  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
21277  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
21278  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21279  CHA.mode = Mode.SIMV
21280  CHA.constant(-0.045)
21281  CHB.mode = Mode.SIMV
21282  CHB.constant(-0.045)
21283  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21284  CHAVSrN45Raw = CHAISrN45Raw = CHBVSrN45Raw = CHBISrN45Raw = 0.0 # initalize measurment variable
21285  for index in range(1000): # calculate average
21286  CHAVSrN45Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21287  CHBVSrN45Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21288  CHAISrN45Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21289  CHBISrN45Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21290 
21291  CHAVSrN45Raw = CHAVSrN45Raw / 1000.0 # calculate average
21292  CHAISrN45Raw = CHAISrN45Raw / 1000.0
21293  CHBVSrN45Raw = CHBVSrN45Raw / 1000.0 # calculate average
21294  CHBISrN45Raw = CHBISrN45Raw / 1000.0
21295  VString = "CA 50 Src -45 " + ' {0:.4f} '.format(CHAVSrN45Raw) # format with 4 decimal places
21296  labelSIAN.config(text = VString) # change displayed value
21297  VString = "CB 50 Src -45 " + ' {0:.4f} '.format(CHBVSrN45Raw) # format with 4 decimal places
21298  labelSIBN.config(text = VString) # change displayed value
21299  # return all switches to open
21300  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
21301  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
21302  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
21303  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21304  # Caculate voltage gain errors
21305  #
21306  CHAF25V = CHAF25vRaw * ( AD584act / CHA584Raw )
21307  CHBF25V = CHBF25vRaw * ( AD584act / CHB584Raw )
21308  #
21309  CHASr5v = CHASr5vRaw * ( AD584act / CHA584Raw ) # calculate actual voltage
21310  CHBSr5v = CHBSr5vRaw * ( AD584act / CHB584Raw ) # calculate actual voltage
21311  #
21312  CHA2p5 = CHA2p5Raw * ( AD584act / CHA584Raw )
21313  # print "calculated fixed 2.5 from CHA ", CHA2p5
21314  CHB2p5 = CHB2p5Raw * ( AD584act / CHB584Raw )
21315  # print "calculated fixed 2.5 from CHB ", CHB2p5
21316  #
21317  CHAActSrI = CHASr5v / OnBoardRes # adjust resistor value to include switch ron
21318  CHBActSrI = CHBSr5v / OnBoardRes # adjust resistor value to include switch ron
21319  #
21320  CHAActSnkI = CHASr0vRaw - CHA2p5 / OnBoardRes # adjust resistor value to include switch ron
21321  CHBActSnkI = CHBSr0vRaw - CHB2p5 / OnBoardRes # adjust resistor value to include switch ron
21322  #
21323  CHASr0i = CHAVSr0iRaw * ( AD584act / CHA584Raw )
21324  CHASr0iAct = CHASr0i / OnBoardRes # adjust resistor value to include switch ron
21325  CHASr100 = CHAVSr100Raw * ( AD584act / CHA584Raw )
21326  CHASrI100Act = (CHASr100 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
21327  CHASrN45 = CHAVSrN45Raw * ( AD584act / CHA584Raw )
21328  CHASrIN45Act = (CHASrN45 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
21329  #
21330  CHBSr0i = CHBVSr0iRaw * ( AD584act / CHB584Raw )
21331  CHBSr0iAct = CHBSr0i / OnBoardRes # adjust resistor value to include switch ron
21332  CHBSr100 = CHBVSr100Raw * ( AD584act / CHB584Raw )
21333  CHBSrI100Act = (CHBSr100 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
21334  CHBSrN45 = CHBVSrN45Raw * ( AD584act / CHB584Raw )
21335  CHBSrIN45Act = (CHBSrN45 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
21336  # Write cal factors to file
21337  #
21338  CalFile.write('# Channel A, measure V\n')
21339  CalFile.write('</>\n')
21340  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAGndRaw) + '>\n')
21341  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHA584Raw) + '>\n')
21342  CalFile.write('<>\n')
21343  CalFile.write('\n')
21344  #
21345  CalFile.write('# Channel A, measure I\n')
21346  CalFile.write('</>\n')
21347  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAI02p5Raw) + '>\n')
21348  CalFile.write('<' + '{0:.4f}'.format(CHAActSrI) + ', ' + '{0:.4f}'.format(CHAISr5vRaw) + '>\n')
21349  # CalFile.write('<' + '{0:.4f}'.format(CHAISr0vRaw) + ', ' + '{0:.4f}'.format(CHAActSnkI) + '>\n')
21350  CalFile.write('<' + '{0:.4f}'.format(-CHAActSrI) + ', ' + '{0:.4f}'.format(-CHAISr5vRaw) + '>\n')
21351  CalFile.write('<>\n')
21352  CalFile.write('\n')
21353  #
21354  CalFile.write('# Channel A, source V\n')
21355  CalFile.write('</>\n')
21356  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAF0vRaw) + '>\n')
21357  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
21358  CalFile.write('<>\n')
21359  CalFile.write('\n')
21360  #
21361  CalFile.write('# Channel A, source I\n')
21362  CalFile.write('</>\n')
21363  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAISr0iRaw) + '>\n')
21364  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHASrI100Act) + '>\n')
21365  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHASrIN45Act) + '>\n')
21366  CalFile.write('<>\n')
21367  CalFile.write('\n')
21368  #
21369  CalFile.write('# Channel B, measure V\n')
21370  CalFile.write('</>\n')
21371  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBGndRaw) + '>\n')
21372  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHB584Raw) + '>\n')
21373  CalFile.write('<>\n')
21374  CalFile.write('\n')
21375  #
21376  CalFile.write('# Channel B, measure I\n')
21377  CalFile.write('</>\n')
21378  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBI02p5Raw) + '>\n')
21379  CalFile.write('<' + '{0:.4f}'.format(CHBActSrI) + ', ' + '{0:.4f}'.format(CHBISr5vRaw) + '>\n')
21380  # CalFile.write('<' + '{0:.4f}'.format(CHBISr0vRaw) + ', ' + '{0:.4f}'.format(CHBActSnkI) + '>\n')
21381  CalFile.write('<' + '{0:.4f}'.format(-CHBActSrI) + ', ' + '{0:.4f}'.format(-CHBISr5vRaw) + '>\n')
21382  CalFile.write('<>\n')
21383  CalFile.write('\n')
21384  #
21385  CalFile.write('# Channel B, source V\n')
21386  CalFile.write('</>\n')
21387  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBF0vRaw) + '>\n')
21388  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
21389  CalFile.write('<>\n')
21390  CalFile.write('\n')
21391  #
21392  CalFile.write('# Channel B source I\n')
21393  CalFile.write('</>\n')
21394  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBISr0iRaw) + '>\n')
21395  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHBSrI100Act) + '>\n')
21396  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHBSrIN45Act) + '>\n')
21397  CalFile.write('<>\n')
21398  #
21399  CalFile.close()
21400  showinfo("Finish","Successfully measured cal factors!", parent=calwindow)
21401  if askyesno("Write cal", "Write Cal Data to Board?", parent=calwindow):
21402  devx.write_calibration(filename)
21403  #print "wrote new " , filename
21404  #
21405  # session.end()
21406  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
21407  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
21408  contloop = 0
21409  discontloop = 1
21410  # session.cancel()
21411  calwindow.destroy()
21412 #
21413 def Save_Cal_file():
21414  global cal, DevID, devx
21415 
21416  devidstr = DevID[17:31]
21417  filename = "calib" + devidstr + "test.txt"
21418  if os.path.isfile(filename):
21419  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?"): #, parent=calwindow):
21420  return
21421  else:
21422  if askyesno("Continue?", "Continue with save calibration file?"): #, parent=calwindow):
21423  donothing()
21424  else:
21425  calwindow.destroy()
21426  return
21427  #
21428  CalFile = open(filename, "w")
21429  #
21430  # Write cal factors to file
21431  # [0]
21432  CalFile.write('# Channel A, measure V\n')
21433  CalFile.write('</>\n')
21434  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[0][0]) + '>\n')
21435  CHAgp = (5.0/cal[0][1])+cal[0][0]
21436  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21437  CalFile.write('<>\n')
21438  CalFile.write('\n')
21439  # [1]
21440  CalFile.write('# Channel A, measure I\n')
21441  CalFile.write('</>\n')
21442  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[1][0]) + '>\n')
21443  CHAgp = (0.1/cal[0][1])+cal[1][0]
21444  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21445  CHAgn = (-0.1/cal[0][2])+cal[1][0]
21446  CalFile.write('<-0.1000' + '{0:.5f}'.format(CHAgn) + '>\n')
21447  CalFile.write('<>\n')
21448  CalFile.write('\n')
21449  # [2]
21450  CalFile.write('# Channel A, source V\n')
21451  CalFile.write('</>\n')
21452  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[2][0]) + '>\n')
21453  CHAgp = (5.0/cal[2][1])+cal[2][0]
21454  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21455  CalFile.write('<>\n')
21456  CalFile.write('\n')
21457  # [3]
21458  CalFile.write('# Channel A, source I\n')
21459  CalFile.write('</>\n')
21460  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[3][0]) + '>\n')
21461  CHAgp = (0.1/cal[3][1])+cal[3][0]
21462  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21463  CHAgn = (-0.1/cal[3][2])+cal[3][0]
21464  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
21465  CalFile.write('<>\n')
21466  CalFile.write('\n')
21467  # [4]
21468  CalFile.write('# Channel B, measure V\n')
21469  CalFile.write('</>\n')
21470  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[4][0]) + '>\n')
21471  CHAgp = (5.0/cal[4][1])+cal[4][0]
21472  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21473  CalFile.write('<>\n')
21474  CalFile.write('\n')
21475  # [5]
21476  CalFile.write('# Channel B, measure I\n')
21477  CalFile.write('</>\n')
21478  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[5][0]) + '>\n')
21479  CHAgp = (0.1/cal[5][1])+cal[5][0]
21480  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21481  CHAgn = (-0.1/cal[5][2])+cal[5][0]
21482  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
21483  CalFile.write('<>\n')
21484  CalFile.write('\n')
21485  # [6]
21486  CalFile.write('# Channel B, source V\n')
21487  CalFile.write('</>\n')
21488  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[6][0]) + '>\n')
21489  CHAgp = (5.0/cal[6][1])+cal[6][0]
21490  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21491  CalFile.write('<>\n')
21492  CalFile.write('\n')
21493  # [7]
21494  CalFile.write('# Channel B source I\n')
21495  CalFile.write('</>\n')
21496  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[7][0]) + '>\n')
21497  CHAgp = (0.1/cal[7][1])+cal[7][0]
21498  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21499  CHAgn = (-0.1/cal[7][2])+cal[7][0]
21500  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
21501  CalFile.write('<>\n')
21502  #
21503  CalFile.close()
21504 
21506 def SPIShiftOut(DValue):
21507  global devx, PIO_0, PIO_1, PIO_2, PIO_3, SCLKPort, SDATAPort, SLATCHPort
21508 
21509  binstr = bin(DValue)
21510  binlen = len(binstr)
21511  datastr = binstr[2:binlen]
21512  datalen = len(datastr)
21513  if datalen < 16:
21514  datastr = str.rjust(datastr , 16 , '0')
21515  datalen = len(datastr)
21516  i = 1
21517  devx.ctrl_transfer(0x40, 0x50, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 0
21518  while i < datalen+1:
21519  # sending 0x50 = set to 0, 0x51 = set to 1
21520  D1code = 0x50 + int(datastr[i-1])
21521  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
21522  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
21523  devx.ctrl_transfer(0x40, 0x50, SCLKPort.get(), 0, 0, 0, 100) # sclk to 0
21524  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
21525  i = i + 1
21526  devx.ctrl_transfer(0x40, 0x51, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 1
21527 #
21528 def SetAD9833(temp):
21529  global FminEntry, HtMulEntry, MinigenFout, MinigenMode, etssrlab, EnableMinigenMode # , Fclk, Fout
21530  global Two28, mclk, EnableHSsampling, MinigenScreenStatus, ETSts, Two_X_Sample
21531 
21532  #
21533  if MinigenScreenStatus.get() == 0:
21534  #SRstring = "ET Sample Rate = " + str(SAMPLErate*MulX)
21535  #etssrlab.config(text=SRstring)
21536  return
21537  #
21538  if EnableMinigenMode == 2:
21539  MinigenMode.set(40)
21540  #
21541  try:
21542  FminE = float(eval(FminEntry.get()))*1000
21543  except:
21544  if EnableHSsampling > 0:
21545  FminEntry.delete(0,END)
21546  FminEntry.insert(0, FminE/1000)
21547  if MulX == 1:
21548  Fmin = FminE
21549  else:
21550  Fmin = FminE - (FminE/MulX)
21551  #
21552  MinigenFout.delete(0,"end")
21553  MinigenFout.insert(0,Fmin)
21554  #
21555  BSendMG()
21556 
21558 def BSendMG():
21559  global MinigenFclk, MinigenFout, MinigenMode
21560  global Two28, SCLKPort, SDATAPort, SLATCHPort
21561 
21562  DValue = 8192 + MinigenMode.get()
21563  SPIShiftOut(DValue)
21564  try:
21565  fout = float(eval(MinigenFout.get()))
21566  except:
21567  MinigenFout.delete(0,"end")
21568  MinigenFout.insert(0,100)
21569  try:
21570  mclk = float(eval(MinigenFclk.get()))*1000000 # convert from MHz to Hz
21571  except:
21572  MingenFclk.delete(0,"end")
21573  MinigenFclk.insert(0,16)
21574  Freg = int((fout*Two28)/mclk)
21575  Foutstr = bin(Freg)
21576  Foutlen = len(Foutstr)
21577  datastr = Foutstr[2:Foutlen]
21578  datalen = len(datastr)
21579  if datalen < 28:
21580  datastr = str.rjust(datastr , 28 , '0')
21581  datalen = len(datastr)
21582  Fmsb = '0b01' + datastr[0:14]
21583  Flsb = '0b01' + datastr[14:]
21584  FValue = int(eval(Flsb))
21585  SPIShiftOut(FValue)
21586  FValue = int(eval(Fmsb))
21587  SPIShiftOut(FValue)
21588 
21590 def MakeMinigenWindow():
21591  global RevDate, minigenwindow, MinigenMode, MinigenScreenStatus, MinigenFclk, MinigenFout, SWRev
21592  global SCLKPort, SDATAPort, SLATCHPort
21593  global GenericSerialStatus
21594  global PIO_0, PIO_1, PIO_2, PIO_3
21595 
21596  if GenericSerialStatus.get() == 1:
21597  GenericSerialStatus.set(0)
21599  if MinigenScreenStatus.get() == 0:
21600  MinigenScreenStatus.set(1)
21601  minigenwindow = Toplevel()
21602  minigenwindow.title("-AD983x DDS- " + SWRev + RevDate)
21603  minigenwindow.resizable(FALSE,FALSE)
21604  minigenwindow.protocol("WM_DELETE_WINDOW", DestroyMinigenScreen)
21605  #
21606  MinigenMode = IntVar(0)
21607  mgb1 = Radiobutton(minigenwindow, text="Sine", variable=MinigenMode, value=0, command=BSendMG )
21608  mgb1.grid(row=1, column=0, sticky=W)
21609  mgb2 = Radiobutton(minigenwindow, text="Triangle", variable=MinigenMode, value=2, command=BSendMG )
21610  mgb2.grid(row=1, column=1, columnspan=2, sticky=W)
21611  mgb3 = Radiobutton(minigenwindow, text="Square", variable=MinigenMode, value=40, command=BSendMG )
21612  mgb3.grid(row=2, column=0, sticky=W)
21613  mgb4 = Radiobutton(minigenwindow, text="Square/2", variable=MinigenMode, value=32, command=BSendMG )
21614  mgb4.grid(row=2, column=1, columnspan=2, sticky=W)
21615  f0lab = Label(minigenwindow, text="Mclk in MHz")
21616  f0lab.grid(row=3, column=0, columnspan=2, sticky=W)
21617  MinigenFclk = Entry(minigenwindow, width=5)
21618  MinigenFclk.grid(row=3, column=1, columnspan=2, sticky=W, padx=6)
21619  MinigenFclk.delete(0,"end")
21620  MinigenFclk.insert(0,16)
21621  f1lab = Label(minigenwindow, text="Output Freq")
21622  f1lab.grid(row=4, column=0, columnspan=2, sticky=W)
21623  MinigenFout = Entry(minigenwindow, width=8, cursor='double_arrow')
21624  MinigenFout.bind('<MouseWheel>', onMiniGenScroll)
21625  MinigenFout.bind("<Button-4>", onMiniGenScroll)# with Linux OS
21626  MinigenFout.bind("<Button-5>", onMiniGenScroll)
21627  MinigenFout.grid(row=4, column=1, columnspan=2, sticky=W)
21628  MinigenFout.delete(0,"end")
21629  MinigenFout.insert(0,100)
21630  bsn1 = Button(minigenwindow, text='UpDate', style="W7.TButton", command=BSendMG)
21631  bsn1.grid(row=5, column=0, sticky=W, pady=4)
21632  dismissmgbutton = Button(minigenwindow, text="Dismiss", style="W8.TButton", command=DestroyMinigenScreen)
21633  dismissmgbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
21634  #
21635  label3 = Label(minigenwindow,text="SCLK PI/O Port ")
21636  label3.grid(row=6, column=0, sticky=W)
21637  sclk1 = Radiobutton(minigenwindow, text="0", variable=SCLKPort, value=PIO_0)
21638  sclk1.grid(row=6, column=1, sticky=W)
21639  sclk2 = Radiobutton(minigenwindow, text="1", variable=SCLKPort, value=PIO_1)
21640  sclk2.grid(row=6, column=2, sticky=W)
21641  sclk3 = Radiobutton(minigenwindow, text="2", variable=SCLKPort, value=PIO_2)
21642  sclk3.grid(row=6, column=3, sticky=W)
21643  sclk4 = Radiobutton(minigenwindow, text="3", variable=SCLKPort, value=PIO_3)
21644  sclk4.grid(row=6, column=4, sticky=W)
21645  #
21646  label4 = Label(minigenwindow,text="SData PI/O Port ")
21647  label4.grid(row=7, column=0, sticky=W)
21648  sdat1 = Radiobutton(minigenwindow, text="0", variable=SDATAPort, value=PIO_0)
21649  sdat1.grid(row=7, column=1, sticky=W)
21650  sdat2 = Radiobutton(minigenwindow, text="1", variable=SDATAPort, value=PIO_1)
21651  sdat2.grid(row=7, column=2, sticky=W)
21652  sdat3 = Radiobutton(minigenwindow, text="2", variable=SDATAPort, value=PIO_2)
21653  sdat3.grid(row=7, column=3, sticky=W)
21654  sdat4 = Radiobutton(minigenwindow, text="3", variable=SDATAPort, value=PIO_3)
21655  sdat4.grid(row=7, column=4, sticky=W)
21656  #
21657  label5 = Label(minigenwindow,text="FSync PI/O Port ")
21658  label5.grid(row=8, column=0, sticky=W)
21659  slth1 = Radiobutton(minigenwindow, text="0", variable=SLATCHPort, value=PIO_0)
21660  slth1.grid(row=8, column=1, sticky=W)
21661  slth2 = Radiobutton(minigenwindow, text="1", variable=SLATCHPort, value=PIO_1)
21662  slth2.grid(row=8, column=2, sticky=W)
21663  slth3 = Radiobutton(minigenwindow, text="2", variable=SLATCHPort, value=PIO_2)
21664  slth3.grid(row=8, column=3, sticky=W)
21665  slth4 = Radiobutton(minigenwindow, text="3", variable=SLATCHPort, value=PIO_3)
21666  slth4.grid(row=8, column=4, sticky=W)
21667  #
21668 
21670 def DestroyMinigenScreen():
21671  global minigenwindow, MinigenScreenStatus
21672 
21673  MinigenScreenStatus.set(0)
21674  minigenwindow.destroy()
21675 #
21676 def onMiniGenScroll(event):
21677  global ETSStatus, ETSDisp
21678 
21679  onTextScroll(event)
21680  BSendMG()
21681 
21683 def DA1ShiftOut(D1Value, D2Value):
21684  global devx
21685  global PIO_0, PIO_1, PIO_2, PIO_3
21686 
21687  binstr = bin(D1Value)
21688  binlen = len(binstr)
21689  data1str = binstr[2:binlen]
21690  datalen = len(data1str)
21691  if datalen < 16:
21692  data1str = str.rjust(data1str , 16 , '0')
21693  datalen = len(data1str)
21694  #
21695  binstr = bin(D2Value)
21696  binlen = len(binstr)
21697  data2str = binstr[2:binlen]
21698  datalen = len(data2str)
21699  if datalen < 16:
21700  data2str = str.rjust(data2str , 16 , '0')
21701  datalen = len(data2str)
21702  # sync --> PIO 0
21703  # D0 --> PIO 1
21704  # D1 --> PIO 2
21705  # SCLK --> PIO 3
21706  i = 1
21707 #
21708  devx.ctrl_transfer(0x40, 0x50, 0, 0, 0, 0, 100) # sync to 0
21709  while i < datalen+1:
21710  # sending 0x50 = set to 0, 0x51 = set to 1
21711  D1code = 0x50 + int(data1str[i-1])
21712  D2code = 0x50 + int(data2str[i-1])
21713  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data 0 bit
21714  devx.ctrl_transfer(0x40, D2code, PIO_2, 0, 0, 0, 100) # data 1 bit
21715  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
21716  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # sclk to 0
21717  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
21718  i = i + 1
21719  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # sync to 1
21720  #
21721 def BSendDA1():
21722  global DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry, REFEntry
21723 
21724  try:
21725  RefValue = float(eval(REFEntry.get()))
21726  except:
21727  RefValue = 3.3
21728  try:
21729  D1Value = float(eval(DAC1Entry.get()))
21730  except:
21731  D1Value = 0.0129
21732  D1Code = int((D1Value/RefValue)*255)
21733  if D1Code > 255:
21734  D1Code = 255
21735  D1Code = D1Code + 0x2000
21736  try:
21737  D2Value = float(eval(DAC2Entry.get()))
21738  except:
21739  D2Value = 0.0129
21740  D2Code = int((D2Value/RefValue)*255)
21741  if D2Code > 255:
21742  D2Code = 255
21743  D2Code = D2Code + 0x2400
21744  try:
21745  D3Value = float(eval(DAC3Entry.get()))
21746  except:
21747  D3Value = 0.0129
21748  D3Code = int((D3Value/RefValue)*255)
21749  if D3Code > 255:
21750  D3Code = 255
21751  D3Code = D3Code + 0x2000
21752  try:
21753  D4Value = float(eval(DAC4Entry.get()))
21754  except:
21755  D4Value = 0.0129
21756  D4Code = int((D4Value/RefValue)*255)
21757  if D4Code > 255:
21758  D4Code = 255
21759  D4Code = D4Code + 0x2400
21760  #
21761  DA1ShiftOut(D1Code, D3Code)
21762  DA1ShiftOut(D2Code, D4Code)
21763 
21765 def MakeDA1Window():
21766  global da1window, DA1ScreenStatus, DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry
21767  global REFEntry, RevDate, SWRev
21768 
21769  if DA1ScreenStatus.get() == 0:
21770  DA1ScreenStatus.set(1)
21771  da1window = Toplevel()
21772  da1window.title("-DA1 PMOD- " + SWRev + RevDate)
21773  da1window.resizable(FALSE,FALSE)
21774  da1window.protocol("WM_DELETE_WINDOW", DestroyDA1Screen)
21775 #
21776  d1lab = Label(da1window, text="DAC A1 output")
21777  d1lab.grid(row=0, column=0, columnspan=1, sticky=W)
21778  DAC1Entry = Entry(da1window, width=5)
21779  DAC1Entry.grid(row=0, column=1, sticky=W)
21780  DAC1Entry.delete(0,"end")
21781  DAC1Entry.insert(0,0)
21782  d2lab = Label(da1window, text="DAC B1 output")
21783  d2lab.grid(row=1, column=0, columnspan=1, sticky=W)
21784  DAC2Entry = Entry(da1window, width=5)
21785  DAC2Entry.grid(row=1, column=1, sticky=W)
21786  DAC2Entry.delete(0,"end")
21787  DAC2Entry.insert(0,0)
21788 
21789  d3lab = Label(da1window, text="DAC A2 output")
21790  d3lab.grid(row=2, column=0, columnspan=1, sticky=W)
21791  DAC3Entry = Entry(da1window, width=5)
21792  DAC3Entry.grid(row=2, column=1, sticky=W)
21793  DAC3Entry.delete(0,"end")
21794  DAC3Entry.insert(0,0)
21795 
21796  d4lab = Label(da1window, text="DAC B2 output")
21797  d4lab.grid(row=3, column=0, columnspan=1, sticky=W)
21798  DAC4Entry = Entry(da1window, width=5)
21799  DAC4Entry.grid(row=3, column=1, sticky=W)
21800  DAC4Entry.delete(0,"end")
21801  DAC4Entry.insert(0,0)
21802 
21803  d5lab = Label(da1window, text="Reference V")
21804  d5lab.grid(row=4, column=0, columnspan=1, sticky=W)
21805  REFEntry = Entry(da1window, width=5)
21806  REFEntry.grid(row=4, column=1, sticky=W)
21807  REFEntry.delete(0,"end")
21808  REFEntry.insert(0,3.3)
21809 
21810  bsn1 = Button(da1window, text='UpDate', style="W7.TButton", command=BSendDA1)
21811  bsn1.grid(row=5, column=0, sticky=W)
21812  dismissdabutton = Button(da1window, text="Dismiss", style="W8.TButton", command=DestroyDA1Screen)
21813  dismissdabutton.grid(row=5, column=1, sticky=W, pady=4)
21814 
21816 def DestroyDA1Screen():
21817  global da1window, DA1ScreenStatus
21818 
21819  DA1ScreenStatus.set(0)
21820  da1window.destroy()
21821 
21822 def DigPotShiftOut(DValue):
21823  global devx, SingleDualPot
21824  global PIO_0, PIO_1, PIO_2, PIO_3
21825 
21826  binstr = bin(DValue)
21827  binlen = len(binstr)
21828  datastr = binstr[2:binlen]
21829  datalen = len(datastr)
21830  if SingleDualPot.get() == 0: # send 10 bits of data
21831  if datalen < 10:
21832  datastr = str.rjust(datastr , 10 , '0')
21833  datalen = len(datastr)
21834  if SingleDualPot.get() == 1: # send 8 bits of data
21835  if datalen < 8:
21836  datastr = str.rjust(datastr , 8 , '0')
21837  datalen = len(datastr)
21838  if SingleDualPot.get() == 2: # send 8 bits of data
21839  if datalen < 8:
21840  datastr = str.rjust(datastr , 8 , '0')
21841  datalen = len(datastr)
21842  i = 1
21843  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
21844  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # CS to 0
21845  while i < datalen+1:
21846  # CS --> PIO 0
21847  # D0 --> PIO 1
21848  # D1 --> PIO 2
21849  # SCLK --> PIO 3
21850  D1code = 0x50 + int(datastr[i-1])
21851  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data bit
21852  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # clock to 1
21853  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
21854  i = i + 1
21855  devx.ctrl_transfer(0x40, 0x51, 0, 0, 0, 0, 100) # CS to 1
21856  #
21857 def DigPotSend(Temp):
21858  global DigPot1, DigPot2, DigPot3, DigPot4, SendPot1, SendPot2, SendPot3, SendPot4
21859  global SingleDualPot
21860 
21861  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
21862  NumTaps = 255
21863  if SingleDualPot.get() == 2:
21864  NumTaps = 63
21865  try:
21866  DValue1 = DigPot1.get()
21867  if DValue1 > NumTaps:
21868  DValue1 = NumTaps
21869  except:
21870  DValue1 = 0
21871  try:
21872  DValue2 = DigPot2.get()
21873  if DValue2 > NumTaps:
21874  DValue2 = NumTaps
21875  except:
21876  DValue2 = 0
21877  try:
21878  DValue3 = DigPot3.get()
21879  if DValue3 > NumTaps:
21880  DValue3 = NumTaps
21881  except:
21882  DValue3 = 0
21883  try:
21884  DValue4 = DigPot4.get()
21885  if DValue4 > NumTaps:
21886  DValue4 = NumTaps
21887  except:
21888  DValue4 = 0
21889  if SendPot1.get() > 0:
21890  DigPotShiftOut(DValue1)
21891  if SendPot2.get() > 0:
21892  DigPotShiftOut(DValue2+NumTaps+1)
21893  if SendPot3.get() > 0:
21894  DigPotShiftOut(DValue3+2*(NumTaps+1))
21895  if SendPot4.get() > 0:
21896  DigPotShiftOut(DValue4+3*(NumTaps+1))
21897 
21898 def UpdatePotSlider():
21899  global SingleDualPot, DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
21900 
21901  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
21902  DPotlabel.config(text="Enter number from 0 to 255")
21903  DigPot1.config(from_=0, to=255, length=256)
21904  DigPot2.config(from_=0, to=255, length=256)
21905  DigPot3.config(from_=0, to=255, length=256)
21906  DigPot4.config(from_=0, to=255, length=256)
21907  if SingleDualPot.get() == 2:
21908  DPotlabel.config(text="Enter number from 0 to 63")
21909  DigPot1.config(from_=0, to=63, length=64)
21910  DigPot2.config(from_=0, to=63, length=64)
21911  DigPot3.config(from_=0, to=63, length=64)
21912  DigPot4.config(from_=0, to=63, length=64)
21913 
21915 def MakeDigPotWindow():
21916  global digpotwindow, DigPotScreenStatus, DigPot1, DigPot2, DigPot3, DigPot4, RevDate
21917  global SendPot1, SendPot2, SendPot3, SendPot4, SingleDualPot, SWRev
21918  global DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
21919 
21920  if DigPotScreenStatus.get() == 0:
21921  DigPotScreenStatus.set(1)
21922  digpotwindow = Toplevel()
21923  digpotwindow.title("Digital Potentiometer " + SWRev + RevDate)
21924  digpotwindow.resizable(FALSE,FALSE)
21925  digpotwindow.protocol("WM_DELETE_WINDOW", DestroyDigPotScreen)
21926  #
21927  SendPot1 = IntVar(0)
21928  SendPot1.set(1)
21929  SendPot2 = IntVar(0)
21930  SendPot2.set(1)
21931  SendPot3 = IntVar(0)
21932  SendPot3.set(0)
21933  SendPot4 = IntVar(0)
21934  SendPot4.set(0)
21935  DPotlabel = Label(digpotwindow,text="Enter number from 0 to 255", style="A12B.TLabel")
21936  DPotlabel.grid(row=0, column=0, columnspan=3, sticky=W)
21937 
21938  SingleDualPot = IntVar(0)
21939  SingleDualPot.set(0)
21940  CompMenu = Menubutton(digpotwindow, text="Sel Comp.", style="W8.TButton")
21941  CompMenu.menu = Menu(CompMenu, tearoff = 0 )
21942  CompMenu["menu"] = CompMenu.menu
21943  CompMenu.menu.add_radiobutton(label="AD840X", variable=SingleDualPot, value=0, command=UpdatePotSlider)
21944  CompMenu.menu.add_radiobutton(label="AD5160", variable=SingleDualPot, value=1, command=UpdatePotSlider)
21945  CompMenu.menu.add_radiobutton(label="AD5203", variable=SingleDualPot, value=2, command=UpdatePotSlider)
21946  CompMenu.grid(row=1, column=0, columnspan=2, sticky=W)
21947  lab1 = Checkbutton(digpotwindow,text="Pot 1", variable=SendPot1)
21948  lab1.grid(row=2, column=0, sticky=W)
21949  DigPot1 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21950  DigPot1.grid(row=3, column=0, columnspan=3, sticky=W)
21951  lab2 = Checkbutton(digpotwindow,text="Pot 2", variable=SendPot2)
21952  lab2.grid(row=4, column=0, sticky=W)
21953  DigPot2 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21954  DigPot2.grid(row=5, column=0, columnspan=3, sticky=W)
21955  lab3 = Checkbutton(digpotwindow,text="Pot 3", variable=SendPot3)
21956  lab3.grid(row=6, column=0, sticky=W)
21957  DigPot3 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21958  DigPot3.grid(row=7, column=0, columnspan=3, sticky=W)
21959  lab4 = Checkbutton(digpotwindow,text="Pot 4", variable=SendPot4)
21960  lab4.grid(row=8, column=0, sticky=W)
21961  DigPot4 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21962  DigPot4.grid(row=9, column=0, columnspan=3, sticky=W)
21963  dismissdpbutton = Button(digpotwindow, text="Dismiss", style="W8.TButton", command=DestroyDigPotScreen)
21964  dismissdpbutton.grid(row=10, column=0, sticky=W, pady=4)
21965 
21966 def DestroyDigPotScreen():
21967  global digpotwindow, DigPotScreenStatus
21968 
21969  DigPotScreenStatus.set(0)
21970  digpotwindow.destroy()
21971 
21972 def BSendGS():
21973  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21974  global NumBitsEntry, DataBitsEntry, devx, SerDirection, DValue, NumBits, AD5626SerialStatus, AD5626Entry
21975 
21976  if AD5626SerialStatus.get() == 0:
21977  try:
21978  DValue = int(eval(DataBitsEntry.get()))
21979  if DValue < 0:
21980  DValue = 0
21981  except:
21982  DValue = 0
21983  try:
21984  NumBits = int(NumBitsEntry.get())
21985  if NumBits < 1:
21986  NumBits = 1
21987  except:
21988  NumBits = 8
21989  else:
21990  try:
21991  DValue = int(eval(AD5626Entry.get())*1000)
21992  if DValue < 0:
21993  DValue = 0
21994  AD5626Entry.delete(0,"end")
21995  AD5626Entry.insert(0,'0.000')
21996  if DValue > 4095:
21997  DValue = 4095
21998  AD5626Entry.delete(0,"end")
21999  AD5626Entry.insert(0,DValue/1000.0)
22000  except:
22001  DValue = 0
22002  AD5626Entry.delete(0,"end")
22003  AD5626Entry.insert(0,'0.000')
22004  NumBits = 12
22005  # print DValue
22006  binstr = bin(DValue)
22007  binlen = len(binstr)
22008  datastr = binstr[2:binlen]
22009  datalen = len(datastr)
22010  if datalen < NumBits:
22011  datastr = str.rjust(datastr , NumBits , '0')
22012  datalen = len(datastr)
22013  if SLatchPhase.get() == 0:
22014  LatchInt = 0x50
22015  LatchEnd = 0x51
22016  else:
22017  LatchInt = 0x51
22018  LatchEnd = 0x50
22019  if AD5626SerialStatus.get() > 0:
22020  LatchInt = 0x51
22021  LatchEnd = 0x50
22022  if SClockPhase.get() == 0:
22023  ClockInt = 0x50
22024  ClockEnd = 0x51
22025  else:
22026  ClockInt = 0x51
22027  ClockEnd = 0x50
22028  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
22029  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
22030  i = 1
22031  while i < datalen+1:
22032  if SerDirection.get() == 1: # for MSB first
22033  D1code = 0x50 + int(datastr[datalen-i]) # 0x50 = set to 0, 0x51 = set to 1
22034  else:
22035  D1code = 0x50 + int(datastr[i-1]) # for LSB first
22036  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
22037  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
22038  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
22039  i = i + 1
22040  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
22041  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
22042  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
22043  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
22044 
22046 def MakeAD5626Window():
22047  global ad5626window, AD5626SerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
22048  global GenericSerialStatus, AD5626Entry, SerDirection, SWRev
22049  global PIO_0, PIO_1, PIO_2, PIO_3
22050 
22051  if GenericSerialStatus.get() == 1:
22052  GenericSerialStatus.set(0)
22054  if AD5626SerialStatus.get() == 0:
22055  AD5626SerialStatus.set(1)
22056  ad5626window = Toplevel()
22057  ad5626window.title("AD5626 Output " + SWRev + RevDate)
22058  ad5626window.resizable(FALSE,FALSE)
22059  ad5626window.protocol("WM_DELETE_WINDOW", DestroyAD5626Screen)
22060 #
22061  SLatchPhase = IntVar(0)
22062  SLatchPhase.set(0)
22063  SClockPhase = IntVar(0)
22064  SClockPhase.set(1)
22065  SerDirection = IntVar(0)
22066  SerDirection.set(0)
22067  #
22068  label2 = Label(ad5626window,text="Enter Output Volts")
22069  label2.grid(row=1, column=0, columnspan=1, sticky=W)
22070  AD5626Entry = Entry(ad5626window, width=10, cursor='double_arrow')
22071  AD5626Entry.bind('<MouseWheel>', onAD5626Scroll)
22072  AD5626Entry.bind("<Button-4>", onAD5626Scroll)# with Linux OS
22073  AD5626Entry.bind("<Button-5>", onAD5626Scroll)
22074  AD5626Entry.grid(row=1, column=1, columnspan=3, sticky=W)
22075  AD5626Entry.delete(0,"end")
22076  AD5626Entry.insert(0,'0.000')
22077  #
22078  label3 = Label(ad5626window,text="SCLK PI/O Port ")
22079  label3.grid(row=2, column=0, columnspan=1, sticky=W)
22080  sclk1 = Radiobutton(ad5626window, text="0", variable=SCLKPort, value=PIO_0)
22081  sclk1.grid(row=2, column=1, sticky=W)
22082  sclk2 = Radiobutton(ad5626window, text="1", variable=SCLKPort, value=PIO_1)
22083  sclk2.grid(row=2, column=2, sticky=W)
22084  sclk3 = Radiobutton(ad5626window, text="2", variable=SCLKPort, value=PIO_2)
22085  sclk3.grid(row=2, column=3, sticky=W)
22086  sclk4 = Radiobutton(ad5626window, text="3", variable=SCLKPort, value=PIO_3)
22087  sclk4.grid(row=2, column=4, sticky=W)
22088  #
22089  label4 = Label(ad5626window,text="SData PI/O Port ")
22090  label4.grid(row=3, column=0, columnspan=1, sticky=W)
22091  sdat1 = Radiobutton(ad5626window, text="0", variable=SDATAPort, value=PIO_0)
22092  sdat1.grid(row=3, column=1, sticky=W)
22093  sdat2 = Radiobutton(ad5626window, text="1", variable=SDATAPort, value=PIO_1)
22094  sdat2.grid(row=3, column=2, sticky=W)
22095  sdat3 = Radiobutton(ad5626window, text="2", variable=SDATAPort, value=PIO_2)
22096  sdat3.grid(row=3, column=3, sticky=W)
22097  sdat4 = Radiobutton(ad5626window, text="3", variable=SDATAPort, value=PIO_3)
22098  sdat4.grid(row=3, column=4, sticky=W)
22099  #
22100  label5 = Label(ad5626window,text="Latch PI/O Port ")
22101  label5.grid(row=4, column=0, columnspan=1, sticky=W)
22102  slth1 = Radiobutton(ad5626window, text="0", variable=SLATCHPort, value=PIO_0)
22103  slth1.grid(row=4, column=1, sticky=W)
22104  slth2 = Radiobutton(ad5626window, text="1", variable=SLATCHPort, value=PIO_1)
22105  slth2.grid(row=4, column=2, sticky=W)
22106  slth3 = Radiobutton(ad5626window, text="2", variable=SLATCHPort, value=PIO_2)
22107  slth3.grid(row=4, column=3, sticky=W)
22108  slth4 = Radiobutton(ad5626window, text="3", variable=SLATCHPort, value=PIO_3)
22109  slth4.grid(row=4, column=4, sticky=W)
22110  #
22111  bsn1 = Button(ad5626window, text='Send', style="W5.TButton", command=BSendGS)
22112  bsn1.grid(row=5, column=0, sticky=W)
22113  dismissgsbutton = Button(ad5626window, text="Dismiss", style="W8.TButton", command=DestroyAD5626Screen)
22114  dismissgsbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
22115 #
22116 def onAD5626Scroll(event):
22117  onTextScroll(event)
22118  BSendGS()
22119 
22120 def DestroyAD5626Screen():
22121  global ad5626window, AD5626SerialStatus
22122 
22123  AD5626SerialStatus.set(0)
22124  ad5626window.destroy()
22125 
22127  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
22128  global NumBitsEntry, DataBitsEntry, SerDirection, RevDate, SWRev
22129  global PIO_0, PIO_1, PIO_2, PIO_3
22130 
22131  if GenericSerialStatus.get() == 0:
22132  GenericSerialStatus.set(1)
22133  serialwindow = Toplevel()
22134  serialwindow.title("Generic Serial Output " + SWRev + RevDate)
22135  serialwindow.resizable(FALSE,FALSE)
22136  serialwindow.protocol("WM_DELETE_WINDOW", DestroyGenericSerialScreen)
22137  #
22138  SCLKPort = IntVar(0)
22139  SCLKPort.set(PIO_2)
22140  SDATAPort = IntVar(0)
22141  SDATAPort.set(PIO_1)
22142  SLATCHPort = IntVar(0)
22143  SLATCHPort.set(PIO_0)
22144  SLatchPhase = IntVar(0)
22145  SClockPhase = IntVar(0)
22146  SerDirection = IntVar(0)
22147  label = Label(serialwindow,text="Enter number of Bits")
22148  label.grid(row=1, column=0, columnspan=2, sticky=W)
22149  NumBitsEntry = Entry(serialwindow, width=3)
22150  NumBitsEntry.grid(row=1, column=2, sticky=W)
22151  NumBitsEntry.delete(0,"end")
22152  NumBitsEntry.insert(0,8)
22153  #
22154  label2 = Label(serialwindow,text="Enter Data Word")
22155  label2.grid(row=2, column=0, columnspan=1, sticky=W)
22156  DataBitsEntry = Entry(serialwindow, width=10)
22157  DataBitsEntry.grid(row=2, column=1, columnspan=3, sticky=W)
22158  DataBitsEntry.delete(0,"end")
22159  DataBitsEntry.insert(0,0)
22160  #
22161  label3 = Label(serialwindow,text="SCLK PI/O Port ")
22162  label3.grid(row=3, column=0, columnspan=1, sticky=W)
22163  sclk1 = Radiobutton(serialwindow, text="0", variable=SCLKPort, value=PIO_0)
22164  sclk1.grid(row=3, column=1, sticky=W)
22165  sclk2 = Radiobutton(serialwindow, text="1", variable=SCLKPort, value=PIO_1)
22166  sclk2.grid(row=3, column=2, sticky=W)
22167  sclk3 = Radiobutton(serialwindow, text="2", variable=SCLKPort, value=PIO_2)
22168  sclk3.grid(row=3, column=3, sticky=W)
22169  sclk4 = Radiobutton(serialwindow, text="3", variable=SCLKPort, value=PIO_3)
22170  sclk4.grid(row=3, column=4, sticky=W)
22171  #
22172  label4 = Label(serialwindow,text="SData PI/O Port ")
22173  label4.grid(row=4, column=0, columnspan=1, sticky=W)
22174  sdat1 = Radiobutton(serialwindow, text="0", variable=SDATAPort, value=PIO_0)
22175  sdat1.grid(row=4, column=1, sticky=W)
22176  sdat2 = Radiobutton(serialwindow, text="1", variable=SDATAPort, value=PIO_1)
22177  sdat2.grid(row=4, column=2, sticky=W)
22178  sdat3 = Radiobutton(serialwindow, text="2", variable=SDATAPort, value=PIO_2)
22179  sdat3.grid(row=4, column=3, sticky=W)
22180  sdat4 = Radiobutton(serialwindow, text="3", variable=SDATAPort, value=PIO_3)
22181  sdat4.grid(row=4, column=4, sticky=W)
22182  #
22183  label5 = Label(serialwindow,text="Latch PI/O Port ")
22184  label5.grid(row=5, column=0, columnspan=1, sticky=W)
22185  slth1 = Radiobutton(serialwindow, text="0", variable=SLATCHPort, value=PIO_0)
22186  slth1.grid(row=5, column=1, sticky=W)
22187  slth2 = Radiobutton(serialwindow, text="1", variable=SLATCHPort, value=PIO_1)
22188  slth2.grid(row=5, column=2, sticky=W)
22189  slth3 = Radiobutton(serialwindow, text="2", variable=SLATCHPort, value=PIO_2)
22190  slth3.grid(row=5, column=3, sticky=W)
22191  slth4 = Radiobutton(serialwindow, text="3", variable=SLATCHPort, value=PIO_3)
22192  slth4.grid(row=5, column=4, sticky=W)
22193  #
22194  label6 = Label(serialwindow,text="Latch Phase ")
22195  label6.grid(row=6, column=0, columnspan=1, sticky=W)
22196  sph1 = Radiobutton(serialwindow, text="0", variable=SLatchPhase, value=0)
22197  sph1.grid(row=6, column=1, sticky=W)
22198  sph2 = Radiobutton(serialwindow, text="1", variable=SLatchPhase, value=1)
22199  sph2.grid(row=6, column=2, sticky=W)
22200  #
22201  label7 = Label(serialwindow,text="Clock Phase ")
22202  label7.grid(row=7, column=0, columnspan=1, sticky=W)
22203  sph7 = Radiobutton(serialwindow, text="0", variable=SClockPhase, value=0)
22204  sph7.grid(row=7, column=1, sticky=W)
22205  sph8 = Radiobutton(serialwindow, text="1", variable=SClockPhase, value=1)
22206  sph8.grid(row=7, column=2, sticky=W)
22207  #
22208  sdir1 = Radiobutton(serialwindow, text="LSB First", variable=SerDirection, value=0 )
22209  sdir1.grid(row=8, column=0, sticky=W)
22210  sdir2 = Radiobutton(serialwindow, text="MSB First", variable=SerDirection, value=1 )
22211  sdir2.grid(row=8, column=1, columnspan=2, sticky=W)
22212 
22213  bsn1 = Button(serialwindow, text='Send', style="W5.TButton", command=BSendGS)
22214  bsn1.grid(row=9, column=0, sticky=W)
22215  dismissgsbutton = Button(serialwindow, text="Dismiss", style="W8.TButton", command=DestroyGenericSerialScreen)
22216  dismissgsbutton.grid(row=9, column=1, columnspan=2, sticky=W, pady=4)
22217 
22219  global serialwindow, GenericSerialStatus
22220 
22221  GenericSerialStatus.set(0)
22222  serialwindow.destroy()
22223 
22225 def MakeDigFiltWindow():
22226  global digfltwindow, DigFiltStatus, RevDate, SWRev, DeBugMode
22227  global DigFiltA, DigFiltB, DifFiltALength, DifFiltBLength, DifFiltAFile, DifFiltBFile
22228  global DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
22229  global BCVASkewEntry, BCVBSkewEntry, DigDeSkewVA, DigDeSkewVB
22230  global BCIASkewEntry, BCIBSkewEntry, DigDeSkewIA, DigDeSkewIB
22231  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, AWGFiltAFile
22232  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength, AWGFiltBFile
22233 
22234  if DigFiltStatus.get() == 0:
22235  DigFiltStatus.set(1)
22236  digfltwindow = Toplevel()
22237  digfltwindow.title("Digital Filter " + SWRev + RevDate)
22238  digfltwindow.resizable(FALSE,FALSE)
22239  digfltwindow.protocol("WM_DELETE_WINDOW", DestroyDigFiltScreen)
22240  #
22241  scriptbutton = Button(digfltwindow, text="Run Script", style="W11.TButton", command=RunScript)
22242  scriptbutton.grid(row=0, column=0, columnspan=1, sticky=W)
22243  dismissdfbutton = Button(digfltwindow, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
22244  dismissdfbutton.grid(row=0, column=1, columnspan=1, sticky=W)
22245  frame2 = LabelFrame(digfltwindow, text="CH A Filter", style="A10R1.TLabelframe")
22246  frame3 = LabelFrame(digfltwindow, text="CH B Filter", style="A10R2.TLabelframe")
22247  #frame2.pack(side=LEFT, expand=1, fill=X)
22248  #frame3.pack(side=LEFT, expand=1, fill=X)
22249  frame2.grid(row=1, column=0, sticky=W)
22250  frame3.grid(row=1, column=1, sticky=W)
22251  frame4 = LabelFrame(digfltwindow, text="AWG A Filter", style="A10R1.TLabelframe")
22252  frame5 = LabelFrame(digfltwindow, text="AWG B Filter", style="A10R2.TLabelframe")
22253  frame4.grid(row=2, column=0, sticky=W)
22254  frame5.grid(row=2, column=1, sticky=W)
22255  #
22256  digfilta = Frame( frame2 )
22257  digfilta.pack(side=LEFT)
22258  #titlab = Label(digfltwindow,text="Apply Digital Filters ", style="A12B.TLabel")
22259  #titlab.grid(row=0, column=0, sticky=W)
22260  lab1 = Checkbutton(digfilta,text="Filter CH A", variable=DigFiltA)
22261  lab1.grid(row=0, column=0, columnspan=2, sticky=W)
22262  lab3 = Checkbutton(digfilta,text="Box Car", variable=DigFiltABoxCar, command=BuildBoxCarA)
22263  lab3.grid(row=1, column=0, sticky=W)
22264  BCALenEntry = Entry(digfilta, width=3, cursor='double_arrow')
22265  BCALenEntry.bind("<Return>", onRetDigFiltA)
22266  BCALenEntry.bind('<MouseWheel>', onDigFiltAScroll)
22267  BCALenEntry.bind("<Button-4>", onDigFiltAScroll)# with Linux OS
22268  BCALenEntry.bind("<Button-5>", onDigFiltAScroll)
22269  # BCALenEntry.bind('<Key>', onTextKey)
22270  BCALenEntry.grid(row=1, column=1, sticky=W)
22271  BCALenEntry.delete(0,"end")
22272  BCALenEntry.insert(0,2)
22273  bcalab = Label(digfilta, text="Length")
22274  bcalab.grid(row=1, column=2, sticky=W)
22275  DifFiltALength = Label(digfilta, text="Length = 0 ")
22276  DifFiltALength.grid(row=2, column=0, sticky=W)
22277  DifFiltAFile = Label(digfilta, text="File Name, none ")
22278  DifFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
22279  cald = Button(digfilta, text='Load From File', command=BLoadDFiltA)
22280  cald.grid(row=4, column=0, columnspan=3, sticky=W)
22281  cacb = Button(digfilta, text='Load From Clip Board', command=BLoadDFiltAClip)
22282  cacb.grid(row=5, column=0, columnspan=3, sticky=W)
22283  camath = Button(digfilta, text='CH A Filter formula', command=BDFiltAMath)
22284  camath.grid(row=6, column=0, columnspan=3, sticky=W)
22285 
22286  # Deskew controls
22287  lab5 = Checkbutton(digfilta, text="DeSkew VA", variable=DigDeSkewVA)# , command=BuildBoxCarA)
22288  lab5.grid(row=7, column=0, sticky=W)
22289  BCVASkewEntry = Entry(digfilta, width=3, cursor='double_arrow')
22290  BCVASkewEntry.bind('<MouseWheel>', onTextScroll)
22291  BCVASkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
22292  BCVASkewEntry.bind("<Button-5>", onTextScroll)
22293  BCVASkewEntry.grid(row=7, column=1, sticky=W)
22294  BCVASkewEntry.delete(0,"end")
22295  BCVASkewEntry.insert(0,0)
22296  bcasklab = Label(digfilta, text="# Samples")
22297  bcasklab.grid(row=7, column=2, sticky=W)
22298  #
22299  lab5i = Checkbutton(digfilta, text="DeSkew IA", variable=DigDeSkewIA)# , command=BuildBoxCarA)
22300  lab5i.grid(row=8, column=0, sticky=W)
22301  BCIASkewEntry = Entry(digfilta, width=3, cursor='double_arrow')
22302  BCIASkewEntry.bind('<MouseWheel>', onTextScroll)
22303  BCIASkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
22304  BCIASkewEntry.bind("<Button-5>", onTextScroll)
22305  BCIASkewEntry.grid(row=8, column=1, sticky=W)
22306  BCIASkewEntry.delete(0,"end")
22307  BCIASkewEntry.insert(0,0)
22308  bcaisklab = Label(digfilta, text="# Samples")
22309  bcaisklab.grid(row=8, column=2, sticky=W)
22310  #
22311  #dismissdfbutton = Button(digfilta, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
22312  #dismissdfbutton.grid(row=7, column=0, columnspan=1, sticky=W)
22313  #
22314  digfiltb = Frame( frame3 )
22315  digfiltb.pack(side=RIGHT)
22316  lab2 = Checkbutton(digfiltb,text="Filter CH B", variable=DigFiltB)
22317  lab2.grid(row=0, column=0, columnspan=2, sticky=W)
22318  lab4 = Checkbutton(digfiltb,text="Box Car", variable=DigFiltBBoxCar, command=BuildBoxCarB)
22319  lab4.grid(row=1, column=0, sticky=W)
22320  BCBLenEntry = Entry(digfiltb, width=3, cursor='double_arrow')
22321  BCBLenEntry.bind("<Return>", onRetDigFiltB)
22322  BCBLenEntry.bind('<MouseWheel>', onDigFiltBScroll)
22323  BCBLenEntry.bind("<Button-4>", onDigFiltBScroll)# with Linux OS
22324  BCBLenEntry.bind("<Button-5>", onDigFiltBScroll)
22325  # BCALenEntry.bind('<Key>', onTextKey)
22326  BCBLenEntry.grid(row=1, column=1, sticky=W)
22327  BCBLenEntry.delete(0,"end")
22328  BCBLenEntry.insert(0,2)
22329  bcblab = Label(digfiltb, text="Length")
22330  bcblab.grid(row=1, column=2, sticky=W)
22331  DifFiltBLength = Label(digfiltb,text="Length = 0 ")
22332  DifFiltBLength.grid(row=2, column=0, sticky=W)
22333  DifFiltBFile = Label(digfiltb,text="File Name, none ")
22334  DifFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
22335  cbld = Button(digfiltb, text='Load From File', command=BLoadDFiltB)
22336  cbld.grid(row=4, column=0, columnspan=3, sticky=W)
22337  cacb = Button(digfiltb, text='Load From Clip Board', command=BLoadDFiltBClip)
22338  cacb.grid(row=5, column=0, columnspan=3, sticky=W)
22339  cbmath = Button(digfiltb, text='CH B Filter formula', command=BDFiltBMath)
22340  cbmath.grid(row=6, column=0, columnspan=3, sticky=W)
22341  # Deskew controls
22342  lab6 = Checkbutton(digfiltb,text="DeSkew VB", variable=DigDeSkewVB)# , command=BuildBoxCarA)
22343  lab6.grid(row=7, column=0, sticky=W)
22344  BCVBSkewEntry = Entry(digfiltb, width=3, cursor='double_arrow')
22345  BCVBSkewEntry.bind('<MouseWheel>', onTextScroll)
22346  BCVBSkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
22347  BCVBSkewEntry.bind("<Button-5>", onTextScroll)
22348  BCVBSkewEntry.grid(row=7, column=1, sticky=W)
22349  BCVBSkewEntry.delete(0,"end")
22350  BCVBSkewEntry.insert(0,0)
22351  bcbsklab = Label(digfiltb, text="# Samples")
22352  bcbsklab.grid(row=7, column=2, sticky=W)
22353  #
22354  lab6i = Checkbutton(digfiltb,text="DeSkew IB", variable=DigDeSkewIB)# , command=BuildBoxCarA)
22355  lab6i.grid(row=8, column=0, sticky=W)
22356  BCIBSkewEntry = Entry(digfiltb, width=3, cursor='double_arrow')
22357  BCIBSkewEntry.bind('<MouseWheel>', onTextScroll)
22358  BCIBSkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
22359  BCIBSkewEntry.bind("<Button-5>", onTextScroll)
22360  BCIBSkewEntry.grid(row=8, column=1, sticky=W)
22361  BCIBSkewEntry.delete(0,"end")
22362  BCIBSkewEntry.insert(0,0)
22363  bcbisklab = Label(digfiltb, text="# Samples")
22364  bcbisklab.grid(row=8, column=2, sticky=W)
22365  # AWG A controls
22366  awgfilta = Frame( frame4 )
22367  awgfilta.pack(side=LEFT)
22368  lab7 = Checkbutton(awgfilta,text="Filter AWG A", variable=AWGFiltA, command=ReMakeAWGwaves)
22369  lab7.grid(row=0, column=0, columnspan=2, sticky=W)
22370  lab8 = Checkbutton(awgfilta,text="Box Car", variable=AWGFiltABoxCar, command=BuildAWGBoxCarA)
22371  lab8.grid(row=1, column=0, sticky=W)
22372  AWGALenEntry = Entry(awgfilta, width=3, cursor='double_arrow')
22373  AWGALenEntry.bind("<Return>", onRetAWGFiltA)
22374  AWGALenEntry.bind('<MouseWheel>', onAWGFiltAScroll)
22375  AWGALenEntry.bind("<Button-4>", onAWGFiltAScroll)# with Linux OS
22376  AWGALenEntry.bind("<Button-5>", onAWGFiltAScroll)
22377  # BCALenEntry.bind('<Key>', onTextKey)
22378  AWGALenEntry.grid(row=1, column=1, sticky=W)
22379  AWGALenEntry.delete(0,"end")
22380  AWGALenEntry.insert(0,2)
22381  awgalab = Label(awgfilta, text="Length")
22382  awgalab.grid(row=1, column=2, sticky=W)
22383  AWGFiltALength = Label(awgfilta, text="Length = 0 ")
22384  AWGFiltALength.grid(row=2, column=0, sticky=W)
22385  AWGFiltAFile = Label(awgfilta, text="File Name, none ")
22386  AWGFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
22387  awgaload = Button(awgfilta, text='Load From File', command=BLoadAWGFiltA)
22388  awgaload.grid(row=4, column=0, columnspan=3, sticky=W)
22389  awgacb = Button(awgfilta, text='Load From Clip Board', command=BLoadAWGAFiltClip)
22390  awgacb.grid(row=5, column=0, columnspan=3, sticky=W)
22391  awgamath = Button(awgfilta, text='AWG A Filter formula', command=BAWGFiltAMath)
22392  awgamath.grid(row=6, column=0, columnspan=3, sticky=W)
22393  #
22394  # AWG B controls
22395  awgfiltb = Frame( frame5 )
22396  awgfiltb.pack(side=RIGHT)
22397  lab9 = Checkbutton(awgfiltb,text="Filter AWG B", variable=AWGFiltB, command=ReMakeAWGwaves)
22398  lab9.grid(row=0, column=0, columnspan=2, sticky=W)
22399  lab10 = Checkbutton(awgfiltb,text="Box Car", variable=AWGFiltBBoxCar, command=BuildAWGBoxCarB)
22400  lab10.grid(row=1, column=0, sticky=W)
22401  AWGBLenEntry = Entry(awgfiltb, width=3, cursor='double_arrow')
22402  AWGBLenEntry.bind("<Return>", onRetAWGFiltB)
22403  AWGBLenEntry.bind('<MouseWheel>', onAWGFiltBScroll)
22404  AWGBLenEntry.bind("<Button-4>", onAWGFiltBScroll)# with Linux OS
22405  AWGBLenEntry.bind("<Button-5>", onAWGFiltBScroll)
22406  # BCALenEntry.bind('<Key>', onTextKey)
22407  AWGBLenEntry.grid(row=1, column=1, sticky=W)
22408  AWGBLenEntry.delete(0,"end")
22409  AWGBLenEntry.insert(0,2)
22410  awgblab = Label(awgfiltb, text="Length")
22411  awgblab.grid(row=1, column=2, sticky=W)
22412  AWGFiltBLength = Label(awgfiltb, text="Length = 0 ")
22413  AWGFiltBLength.grid(row=2, column=0, sticky=W)
22414  AWGFiltBFile = Label(awgfiltb, text="File Name, none ")
22415  AWGFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
22416  awgbload = Button(awgfiltb, text='Load From File', command=BLoadAWGFiltB)
22417  awgbload.grid(row=4, column=0, columnspan=3, sticky=W)
22418  awgbcb = Button(awgfiltb, text='Load From Clip Board', command=BLoadAWGBFiltClip)
22419  awgbcb.grid(row=5, column=0, columnspan=3, sticky=W)
22420  awgbmath = Button(awgfiltb, text='AWG B Filter formula', command=BAWGFiltBMath)
22421  awgbmath.grid(row=6, column=0, columnspan=3, sticky=W)
22422  #
22423 def onRetDigFiltA(event):
22424  BuildBoxCarA()
22425 
22426 def onDigFiltAScroll(event):
22427  onTextScroll(event)
22428  BuildBoxCarA()
22429 
22430 def BuildBoxCarA():
22431  global BCALenEntry, DFiltACoef, DigFiltABoxCar, DifFiltALength
22432 
22433  if DigFiltABoxCar.get() == 0:
22434  return
22435 
22436  FLength = int(BCALenEntry.get())
22437  if FLength < 2:
22438  return
22439 
22440  DFiltACoef = [] # empty coef array
22441 
22442  for n in range(FLength):
22443  DFiltACoef.append(float(1.0/FLength))
22444 
22445  DFiltACoef = numpy.array(DFiltACoef)
22446  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
22447 
22448 def onRetDigFiltB(event):
22449  BuildBoxCarB()
22450 
22451 def onDigFiltBScroll(event):
22452  onTextScroll(event)
22453  BuildBoxCarB()
22454 
22455 def BuildBoxCarB():
22456  global BCBLenEntry, DFiltBCoef, DigFiltBBoxCar, DifFiltBLength
22457 
22458  if DigFiltBBoxCar.get() == 0:
22459  return
22460 
22461  FLength = int(BCBLenEntry.get())
22462  if FLength < 2:
22463  return
22464 
22465  DFiltBCoef = [] # empty coef array
22466 
22467  for n in range(FLength):
22468  DFiltBCoef.append(float(1.0/FLength))
22469 
22470  DFiltBCoef = numpy.array(DFiltBCoef)
22471  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
22472 
22473 def DestroyDigFiltScreen():
22474  global digfltwindow, DigFiltStatus
22475 
22476  DigFiltStatus.set(0)
22477  digfltwindow.destroy()
22478 
22479 def BLoadDFiltA():
22480  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile
22481 
22482 # Read values from CVS file
22483  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
22484  try:
22485  CSVFile = open(filename)
22486  csv_f = csv.reader(CSVFile)
22487  except:
22488  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
22489  return
22490  DFiltACoef = []
22491 
22492  for row in csv_f:
22493  try:
22494  DFiltACoef.append(float(row[0]))
22495  except:
22496  print( 'skipping non-numeric row')
22497  DFiltACoef = numpy.array(DFiltACoef)
22498  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
22499  DifFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
22500  CSVFile.close()
22501 #
22502 def BDFiltAMath():
22503  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile, DigFilterAString
22504 
22505  TempString = DigFilterAString
22506  DigFilterAString = askstring("CH A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=DigFilterAString, parent=digfltwindow)
22507  if (DigFilterAString == None): # If Cancel pressed, then None
22508  DigFilterAString = TempString
22509  return
22510  DFiltACoef = eval(DigFilterAString)
22511  DFiltACoef = numpy.array(DFiltACoef)
22512  coefsum = numpy.sum(DFiltACoef)
22513  DFiltACoef = DFiltACoef / coefsum # always normalize to a gain of one
22514  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
22515  DifFiltAFile.config(text = "Using Filter A formula" ) # change displayed file name
22516 
22517 def BLoadDFiltB():
22518  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile
22519 
22520 # Read values from CVS file
22521  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
22522  try:
22523  CSVFile = open(filename)
22524  csv_f = csv.reader(CSVFile)
22525  except:
22526  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
22527  return
22528  DFiltBCoef = []
22529 
22530  for row in csv_f:
22531  try:
22532  DFiltBCoef.append(float(row[0]))
22533  except:
22534  print( 'skipping non-numeric row')
22535  DFiltBCoef = numpy.array(DFiltBCoef)
22536  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
22537  DifFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
22538  CSVFile.close()
22539 #
22540 def BDFiltBMath():
22541  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile, DigFilterBString
22542 
22543  TempString = DigFilterBString
22544  DigFilterBString = askstring("CH B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=DigFilterBString, parent=digfltwindow)
22545  if (DigFilterBString == None): # If Cancel pressed, then None
22546  DigFilterBString = TempString
22547  return
22548  DFiltBCoef = eval(DigFilterBString)
22549  DFiltBCoef = numpy.array(DFiltBCoef)
22550  coefsum = numpy.sum(DFiltBCoef)
22551  DFiltBCoef = DFiltBCoef / coefsum
22552  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
22553  DifFiltBFile.config(text = "Using Filter B formula" ) # change displayed file name
22554 #
22555 def onRetAWGFiltA(event):
22556  BuildAWGBoxCarA()
22557 
22558 def onAWGFiltAScroll(event):
22559  onTextScroll(event)
22560  BuildAWGBoxCarA()
22561 
22562 def BuildAWGBoxCarA():
22563  global AWGALenEntry, AWGFiltACoef, AWGFiltABoxCar, AWGFiltALength
22564 
22565  if AWGFiltABoxCar.get() == 0:
22566  return
22567 
22568  FLength = int(AWGALenEntry.get())
22569  if FLength < 2:
22570  return
22571 
22572  AWGFiltACoef = [] # empty coef array
22573 
22574  for n in range(FLength):
22575  AWGFiltACoef.append(float(1.0/FLength))
22576 
22577  AWGFiltACoef = numpy.array(AWGFiltACoef)
22578  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
22579  ReMakeAWGwaves()
22580 #
22581 def onRetAWGFiltB(event):
22582  BuildAWGBoxCarb()
22583 
22584 def onAWGFiltBScroll(event):
22585  onTextScroll(event)
22586  BuildAWGBoxCarB()
22587 
22588 def BuildAWGBoxCarB():
22589  global AWGBLenEntry, AWGFiltBCoef, AWGFiltBBoxCar, AWGFiltBLength
22590 
22591  if AWGFiltBBoxCar.get() == 0:
22592  return
22593 
22594  FLength = int(AWGBLenEntry.get())
22595  if FLength < 2:
22596  return
22597 
22598  AWGFiltBCoef = [] # empty coef array
22599 
22600  for n in range(FLength):
22601  AWGFiltBCoef.append(float(1.0/FLength))
22602 
22603  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
22604  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
22605  ReMakeAWGwaves()
22606 #
22607 def BLoadAWGFiltA():
22608  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile
22609 
22610 # Read values from CVS file
22611  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
22612  try:
22613  CSVFile = open(filename)
22614  csv_f = csv.reader(CSVFile)
22615  except:
22616  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
22617  return
22618  AWGFiltACoef = []
22619 
22620  for row in csv_f:
22621  try:
22622  AWGFiltACoef.append(float(row[0]))
22623  except:
22624  print( 'skipping non-numeric row')
22625  AWGFiltACoef = numpy.array(AWGFiltACoef)
22626  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
22627  AWGFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
22628  CSVFile.close()
22629  ReMakeAWGwaves()
22630 #
22631 def BAWGFiltAMath():
22632  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile, AWGFilterAString
22633 
22634  TempString = AWGFilterAString
22635  AWGFilterAString = askstring("AWG A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=AWGFilterAString, parent=digfltwindow)
22636  if (AWGFilterAString == None): # If Cancel pressed, then None
22637  AWGFilterAString = TempString
22638  return
22639  AWGFiltACoef = eval(AWGFilterAString)
22640  AWGFiltACoef = numpy.array(AWGFiltACoef)
22641  coefsum = numpy.sum(AWGFiltACoef)
22642  AWGFiltACoef = AWGFiltACoef / coefsum
22643  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
22644  AWGFiltAFile.config(text = "AWG A Filter formula" ) # change displayed file name
22645  ReMakeAWGwaves()
22646 #
22647 #
22648 def BLoadAWGFiltB():
22649  global AWGFiltBCoef, digfltwindow, AWGFiltbLength, AWGFiltBFile
22650 
22651 # Read values from CVS file
22652  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
22653  try:
22654  CSVFile = open(filename)
22655  csv_f = csv.reader(CSVFile)
22656  except:
22657  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
22658  return
22659  AWGFiltBCoef = []
22660 
22661  for row in csv_f:
22662  try:
22663  AWGFiltBCoef.append(float(row[0]))
22664  except:
22665  print( 'skipping non-numeric row')
22666  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
22667  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
22668  AWGFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
22669  CSVFile.close()
22670  ReMakeAWGwaves()
22671 #
22672 def BAWGFiltBMath():
22673  global AWGFiltBCoef, digfltwindow, AWGFiltBLength, AWGFiltBFile, AWGFilterBString
22674 
22675  TempString = AWGFilterBString
22676  AWGFilterBString = askstring("AWG B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=AWGFilterBString, parent=digfltwindow)
22677  if (AWGFilterBString == None): # If Cancel pressed, then None
22678  AWGFilterBString = TempString
22679  return
22680  AWGFiltBCoef = eval(AWGFilterBString)
22681  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
22682  coefsum = numpy.sum(AWGFiltBCoef)
22683  AWGFiltBCoef = AWGFiltBCoef / coefsum
22684  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
22685  AWGFiltBFile.config(text = "AWG B Filter formula" ) # change displayed file name
22686  ReMakeAWGwaves()
22687 #
22688 # Higher order SINC filters can be generated by convolving first order Box Car filters
22689 def BuildRejectFilter(Order, Freject, Fsample):
22690  # Order can be 1, 2, 3 or 4
22691  # Fsample = 100000
22692  # Calculate SINC1 oversample ratios for Freject
22693  osr = int(Fsample/Freject) #
22694  # osr60 = int(Fsample/60) # 60 Hz example
22695  # Create "boxcar" SINC1 filter
22696  sinc1 = numpy.ones(osr)
22697  # sinc1_60 = np.ones(osr60)
22698  # Calculate higher order filters
22699  sinc2 = numpy.convolve(sinc1, sinc1)
22700  sinc3 = numpy.convolve(sinc2, sinc1)
22701  sinc4 = numpy.convolve(sinc2, sinc2)
22702  fosr = float(Fsample/Freject)
22703  if Order == 1:
22704  return sinc1/fosr
22705  elif Order == 2:
22706  return sinc2/fosr
22707  elif Order == 3:
22708  return sinc3/fosr
22709  elif Order == 4:
22710  return sinc4/fosr
22711  else:
22712  return sinc1/fosr
22713  # Here's the SINC4-ish filter
22714  # with three zeros at 50Hz, one at 60Hz.
22715  # filt_50_60_rej = np.convolve(sinc3_50, sinc1_60)
22716 
22717 # Fit the function y = A * exp(B * x) to the data arrays xs and ys
22718 # returns (A, B)
22719 # From: https://mathworld.wolfram.com/LeastSquaresFittingExponential.html
22720 def fit_exp(xs, ys):
22721  S_x2_y = 0.0
22722  S_y_lny = 0.0
22723  S_x_y = 0.0
22724  S_x_y_lny = 0.0
22725  S_y = 0.0
22726  for (x,y) in zip(xs, ys):
22727  S_x2_y += x * x * y
22728  S_y_lny += y * numpy.log(y)
22729  S_x_y += x * y
22730  S_x_y_lny += x * y * numpy.log(y)
22731  S_y += y
22732  #end
22733  a = (S_x2_y * S_y_lny - S_x_y * S_x_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
22734  b = (S_y * S_x_y_lny - S_x_y * S_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
22735  return (numpy.exp(a), b)
22736 #
22737 def MakeCommandScreen():
22738  global commandwindow, CommandStatus, ExecString, LastCommand, RevDate, SWRev
22739 
22740  if CommandStatus.get() == 0:
22741  CommandStatus.set(1)
22742  commandwindow = Toplevel()
22743  commandwindow.title("Command Line " + SWRev + RevDate)
22744  commandwindow.resizable(FALSE,FALSE)
22745  commandwindow.protocol("WM_DELETE_WINDOW", DestroyCommandScreen)
22746  toplab = Label(commandwindow,text="Command Line Interface ", style="A12B.TLabel")
22747  toplab.grid(row=0, column=0, columnspan=4, sticky=W)
22748  cl1 = Label(commandwindow,text="Last command:")
22749  cl1.grid(row=1, column=0, sticky=W)
22750  LastCommand = Label(commandwindow,text=" ")
22751  LastCommand.grid(row=2, column=0, columnspan=4, sticky=W)
22752  ExecString = Entry(commandwindow, width=40)
22753  ExecString.bind("<Return>", RExecuteFromString)
22754  ExecString.grid(row=3, column=0, columnspan=4, sticky=W)
22755  ExecString.delete(0,"end")
22756  ExecString.insert(0,"")
22757  executeclbutton = Button(commandwindow, text="Execute", style="W8.TButton", command=BExecuteFromString)
22758  executeclbutton.grid(row=4, column=0, sticky=W, pady=8)
22759  scriptbutton = Button(commandwindow, text="Run Script", style="W10.TButton", command=RunScript)
22760  scriptbutton.grid(row=4, column=1, sticky=W, pady=8)
22761  #
22762  dismissclbutton = Button(commandwindow, text="Dismiss", style="W8.TButton", command=DestroyCommandScreen)
22763  dismissclbutton.grid(row=4, column=2, sticky=W, pady=7)
22764 
22765 def DestroyCommandScreen():
22766  global commandwindow, CommandStatus
22767 
22768  CommandStatus.set(0)
22769  commandwindow.destroy()
22770 
22771 def RExecuteFromString(temp):
22772 
22774 
22775 def BExecuteFromString(): # global VBuffA,AWGAwaveform;VBuffA=AWGAwaveform
22776  global ExecString, LastCommand
22777  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
22778  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
22779  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
22780  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
22781  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
22782  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
22783  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
22784  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
22785  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
22786  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
22787  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
22788  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
22789  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
22790  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
22791  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
22792  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
22793  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
22794  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
22795  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
22796  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
22797  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
22798  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
22799  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
22800  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
22801  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
22802  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
22803  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
22804  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
22805  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
22806  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
22807  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
22808  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
22809  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
22810  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
22811  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
22812  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
22813  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
22814  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
22815  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
22816  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
22817  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
22818  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
22819  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
22820  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
22821  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
22822  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
22823  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
22824  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
22825  global phawindow, PhAca, PhAScreenStatus, PhADisp
22826  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
22827  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
22828  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
22829  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
22830  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
22831  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
22832  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
22833  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
22834  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
22835 
22836  try:
22837  exec( ExecString.get(), globals(), globals())
22838  # exec( ExecString.get() )
22839  LastCommand.config(text = ExecString.get() ) # change displayed last command
22840  except:
22841  LastCommand.config(text = "Syntax Error Encountered" ) # change displayed last command
22842  return()
22843 #
22844 def CAresize(event):
22845  global ca, GRW, XOL, GRH, Y0T, CANVASwidth, CANVASheight, FontSize
22846 
22847  XOL = FontSize * 7
22848  CANVASwidth = event.width - 4
22849  CANVASheight = event.height - 4
22850  GRW = CANVASwidth - (2 * X0L) # new grid width
22851  GRH = CANVASheight - (Y0T + (FontSize * 7)) # new grid height
22852  UpdateTimeAll()
22853 #
22854 def UpdateMeasureScreen():
22855  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
22856  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
22857  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
22858  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
22859  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
22860  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
22861 
22862  ValueText = ' {0:.4f} '.format(eval(ChaMeasString1))
22863  ChaValue1.config(text = ValueText)
22864  ValueText = ' {0:.4f} '.format(eval(ChaMeasString2))
22865  ChaValue2.config(text = ValueText)
22866  ValueText = ' {0:.4f} '.format(eval(ChaMeasString3))
22867  ChaValue3.config(text = ValueText)
22868  ValueText = ' {0:.4f} '.format(eval(ChaMeasString4))
22869  ChaValue4.config(text = ValueText)
22870  ValueText = ' {0:.4f} '.format(eval(ChaMeasString5))
22871  ChaValue5.config(text = ValueText)
22872  ValueText = ' {0:.4f} '.format(eval(ChaMeasString6))
22873  ChaValue6.config(text = ValueText)
22874  ValueText = ' {0:.4f} '.format(eval(ChbMeasString1))
22875  ChbValue1.config(text = ValueText)
22876  ValueText = ' {0:.4f} '.format(eval(ChbMeasString2))
22877  ChbValue2.config(text = ValueText)
22878  ValueText = ' {0:.4f} '.format(eval(ChbMeasString3))
22879  ChbValue3.config(text = ValueText)
22880  ValueText = ' {0:.4f} '.format(eval(ChbMeasString4))
22881  ChbValue4.config(text = ValueText)
22882  ValueText = ' {0:.4f} '.format(eval(ChbMeasString5))
22883  ChbValue5.config(text = ValueText)
22884  ValueText = ' {0:.4f} '.format(eval(ChbMeasString6))
22885  ChbValue6.config(text = ValueText)
22886 #
22887 def MakeMeasureScreen():
22888  global measurewindow, MeasureStatus, RevDate, SWRev
22889  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
22890  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
22891  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
22892  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
22893  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
22894  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
22895 
22896  if MeasureStatus.get() == 0:
22897  MeasureStatus.set(1)
22898  measurewindow = Toplevel()
22899  measurewindow.title("Measurements " + SWRev + RevDate)
22900  measurewindow.resizable(FALSE,FALSE)
22901  measurewindow.protocol("WM_DELETE_WINDOW", DestroyMeasureScreen)
22902  toplab = Label(measurewindow,text="Measurements ", style="A12B.TLabel")
22903  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
22904  ChaLab1 = Label(measurewindow,text=ChaLableSrring1, style="A10B.TLabel")
22905  ChaLab1.grid(row=1, column=0, columnspan=1, sticky=W)
22906  ChaValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22907  ChaValue1.grid(row=1, column=1, columnspan=1, sticky=W)
22908  ChaLab2 = Label(measurewindow,text=ChaLableSrring2, style="A10B.TLabel")
22909  ChaLab2.grid(row=1, column=2, columnspan=1, sticky=W)
22910  ChaValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22911  ChaValue2.grid(row=1, column=3, columnspan=1, sticky=W)
22912  ChaLab3 = Label(measurewindow,text=ChaLableSrring3, style="A10B.TLabel")
22913  ChaLab3.grid(row=2, column=0, columnspan=1, sticky=W)
22914  ChaValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22915  ChaValue3.grid(row=2, column=1, columnspan=1, sticky=W)
22916  ChaLab4 = Label(measurewindow,text=ChaLableSrring4, style="A10B.TLabel")
22917  ChaLab4.grid(row=2, column=2, columnspan=1, sticky=W)
22918  ChaValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22919  ChaValue4.grid(row=2, column=3, columnspan=1, sticky=W)
22920  ChaLab5 = Label(measurewindow,text=ChaLableSrring5, style="A10B.TLabel")
22921  ChaLab5.grid(row=3, column=0, columnspan=1, sticky=W)
22922  ChaValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22923  ChaValue5.grid(row=3, column=1, columnspan=1, sticky=W)
22924  ChaLab6 = Label(measurewindow,text=ChaLableSrring6, style="A10B.TLabel")
22925  ChaLab6.grid(row=3, column=2, columnspan=1, sticky=W)
22926  ChaValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22927  ChaValue6.grid(row=3, column=3, columnspan=1, sticky=W)
22928  #
22929  ChbLab1 = Label(measurewindow,text=ChbLableSrring1, style="A10B.TLabel")
22930  ChbLab1.grid(row=4, column=0, columnspan=1, sticky=W)
22931  ChbValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22932  ChbValue1.grid(row=4, column=1, columnspan=1, sticky=W)
22933  ChbLab2 = Label(measurewindow,text=ChbLableSrring2, style="A10B.TLabel")
22934  ChbLab2.grid(row=4, column=2, columnspan=1, sticky=W)
22935  ChbValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22936  ChbValue2.grid(row=4, column=3, columnspan=1, sticky=W)
22937  ChbLab3 = Label(measurewindow,text=ChbLableSrring3, style="A10B.TLabel")
22938  ChbLab3.grid(row=5, column=0, columnspan=1, sticky=W)
22939  ChbValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22940  ChbValue3.grid(row=5, column=1, columnspan=1, sticky=W)
22941  ChbLab4 = Label(measurewindow,text=ChbLableSrring4, style="A10B.TLabel")
22942  ChbLab4.grid(row=5, column=2, columnspan=1, sticky=W)
22943  ChbValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22944  ChbValue4.grid(row=5, column=3, columnspan=1, sticky=W)
22945  ChbLab5 = Label(measurewindow,text=ChbLableSrring5, style="A10B.TLabel")
22946  ChbLab5.grid(row=6, column=0, columnspan=1, sticky=W)
22947  ChbValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22948  ChbValue5.grid(row=6, column=1, columnspan=1, sticky=W)
22949  ChbLab6 = Label(measurewindow,text=ChbLableSrring6, style="A10B.TLabel")
22950  ChbLab6.grid(row=6, column=2, columnspan=1, sticky=W)
22951  ChbValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22952  ChbValue6.grid(row=6, column=3, columnspan=1, sticky=W)
22953 #
22954 def DestroyMeasureScreen():
22955  global measurewindow, MeasureStatus
22956 
22957  MeasureStatus.set(0)
22958  measurewindow.destroy()
22959 #
22960 def MakeBoardScreen():
22961  global boardwindow, BoardStatus, session, devx, dev0, dev1, dev2, MultipleBoards
22962  global RevDate, BrdSel, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
22963 
22964  if len(session.devices) > 1 and MultipleBoards.get() > 0: # make screen only if more than one board present
22965  if BoardStatus.get() == 0:
22966  BoardStatus.set(1)
22967  boardwindow = Toplevel()
22968  boardwindow.title("Select Board " + RevDate)
22969  boardwindow.resizable(FALSE,FALSE)
22970  boardwindow.protocol("WM_DELETE_WINDOW", DestroyBoardScreen)
22971  toplab = Label(boardwindow,text="- Select ALM1000 -", style="A12B.TLabel")
22972  toplab.pack(side=TOP)
22973  for idx, devx in enumerate(session.devices):
22974  BrdText = "Board # " + str(idx)
22975  if idx == 0:
22976  devx.set_led(0b010) # LED.green
22977  FWRevOne = float(devx.fwver)
22978  HWRevOne = devx.hwver
22979  dev0 = devx #session.devices[0]
22980  brd = Radiobutton(boardwindow, text=BrdText, style="Run.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
22981  elif idx == 1:
22982  devx.set_led(0b100) # LED.blue,
22983  FWRevTwo = float(devx.fwver)
22984  HWRevTwo = devx.hwver
22985  dev1 = devx #session.devices[1]
22986  brd = Radiobutton(boardwindow, text=BrdText, style="Stop.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
22987  elif idx == 2:
22988  devx.set_led(0b001) # LED.red,
22989  FWRevThree = float(devx.fwver)
22990  HWRevThree = devx.hwver
22991  dev2 = devx #session.devices[2]
22992  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
22993  else:
22994  dev3 = session.devices[3]
22995  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
22996  brd.pack(side=TOP)
22997  else:
22998  devx = session.devices[0]
22999  # devx.ignore_dataflow = True
23000  devx.set_led(0b010) # if only one board set LED.green
23001  try:
23002  FWRevOne = float(devx.fwver)
23003  HWRevOne = devx.hwver
23004  except:
23005  FWRevOne = "Before 2.06"
23006  HWRevOne = "?"
23007  dev0 = session.devices[0]
23008 #
23009 def DestroyBoardScreen():
23010  global boardwindow, BoardStatus
23011 
23012  BoardStatus.set(0)
23013  boardwindow.destroy()
23014 #
23015 def ConnectDevice():
23016  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples, AWGSAMPLErate
23017  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree, SAMPLErate, MultipleBoards
23018 
23019  if DevID == "No Device" or DevID == "m1k":
23020  #print("Request sample rate: " + str(SAMPLErate))
23021  session = Session(ignore_dataflow=True, sample_rate=SAMPLErate, queue_size=MaxSamples)
23022  # session.add_all()
23023  # SAMPLErate = 200000 #AWGSAMPLErate # Scope sample rate
23024  if not session.devices:
23025  print( 'No Device plugged IN!')
23026  DevID = "No Device"
23027  FWRevOne = 0.0
23028  HWRevOne = "?"
23029  bcon.configure(text="Recon", style="RConn.TButton")
23030  return
23031  session.configure(sample_rate=SAMPLErate)
23032  # print("Session sample rate: " + str(session.sample_rate))
23033  MakeBoardScreen()
23034  SelectBoard()
23035  bcon.configure(text="Conn", style="GConn.TButton")
23036  devx.set_adc_mux(0)
23037  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
23038  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set not addr DAC B
23039 
23043  session.start(0)
23044 #
23045 def SelectBoard():
23046  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, RUNstatus, FWRevOne, HWRevOne
23047  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7, cal, SAMPLErate, MaxSamples
23048  global IgnoreFirmwareCheck, SDATAPort, SCLKPort, SLATCHPort
23049 
23050  if RUNstatus.get() == 1:
23051  BStop()
23052  print( "STOP")
23053 
23054  if BrdSel.get() == 0:
23055  try:
23056  session.remove(dev1)
23057  print( "Removing dev1")
23058  except:
23059  print( "Skipping dev1")
23060  try:
23061  session.remove(dev2)
23062  print( "Removing dev2")
23063  except:
23064  print( "Skipping dev2")
23065  session.add(dev0)
23066  devx = dev0
23067  #session.add(devx)
23068  if BrdSel.get() == 1:
23069  try:
23070  session.remove(dev0)
23071  print( "Removing dev0")
23072  except:
23073  print( "Skipping dev0")
23074  try:
23075  session.remove(dev2)
23076  print( "Removing dev2")
23077  except:
23078  print( "Skipping dev2")
23079  session.add(dev1)
23080  devx = dev1
23081  #session.add(devx)
23082  DevID = devx.serial
23083  print( DevID)
23084  FWRevOne = float(devx.fwver)
23085  HWRevOne = str(devx.hwver)
23086  print( FWRevOne, HWRevOne)
23087  # print("Session sample rate: " + str(session.sample_rate))
23088 
23089  if IgnoreFirmwareCheck == 0:
23090  if FWRevOne < 2.17:
23091  showwarning("WARNING","This ALICE version Requires Firmware version > 2.16")
23092  UpdateFirmware()
23093  cal = devx.calibration
23094  CHA = devx.channels['A'] # Open CHA
23095  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
23096  CHB = devx.channels['B'] # Open CHB
23097  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
23098  #
23099  # if session.continuous == 0:
23100  #session.start(0)
23101 
23110  devx.set_adc_mux(0)
23111  if devx.hwver == "F":
23112  print( "Rev F Board I/O ports set")
23113  PIO_0 = 28
23114  PIO_1 = 29
23115  PIO_2 = 47
23116  PIO_3 = 3
23117  PIO_4 = 4
23118  PIO_5 = 5
23119  PIO_6 = 6
23120  PIO_7 = 7
23121  else:
23122  PIO_0 = 0
23123  PIO_1 = 1
23124  PIO_2 = 2
23125  PIO_3 = 3
23126  PIO_4 = 4
23127  PIO_5 = 5
23128  PIO_6 = 6
23129  PIO_7 = 7
23130 #
23131  SDATAPort.set(PIO_1)
23132  SCLKPort.set(PIO_2)
23133  SLATCHPort.set(PIO_0)
23134 
23135 def MakeSampleRateMenu():
23136  global SAMPLErate, AWGSAMPLErate, BaseSampleRate, session, ETSStatus, etssrlab, RevDate
23137  global Two_X_Sample, ADC_Mux_Mode, SampleRatewindow, SampleRateStatus, BaseRatesb
23138  global Alternate_Sweep_Mode, DeBugMode, FWRevOne, SWRev, SampRateList
23139  global FrameRefief, BorderSize
23140 
23141  if SampleRateStatus.get() == 0:
23142  SampleRateStatus.set(1)
23143  SampleRatewindow = Toplevel()
23144  SampleRatewindow.title("Set Sample Rate " + SWRev + RevDate)
23145  SampleRatewindow.resizable(FALSE,FALSE)
23146  SampleRatewindow.protocol("WM_DELETE_WINDOW", DestroySampleRate)
23147  frame1 = Frame(SampleRatewindow, borderwidth=BorderSize, relief=FrameRefief)
23148  frame1.grid(row=0, column=0, sticky=W)
23149  #
23150  BaseRATE = Frame( frame1 )
23151  BaseRATE.grid(row=0, column=0, sticky=W)
23152  baseratelab = Label(BaseRATE, text="Base Sample Rate", style="A10B.TLabel") #, font = "Arial 10 bold")
23153  baseratelab.pack(side=LEFT)
23154  BaseRatesb = Spinbox(BaseRATE, width=6, values=SampRateList, command=SetSampleRate)
23155  BaseRatesb.bind('<MouseWheel>', onSrateScroll)
23156  BaseRatesb.bind("<Button-4>", onSrateScroll)# with Linux OS
23157  BaseRatesb.bind("<Button-5>", onSrateScroll)
23158  BaseRatesb.bind("<Return>", onRetSrate)
23159  BaseRatesb.pack(side=LEFT)
23160  BaseRatesb.delete(0,"end")
23161  BaseRatesb.insert(0,BaseSampleRate)
23162  #
23163  nextrow = 2
23164  if FWRevOne > 2.16:
23165  twoX = Checkbutton(frame1, text="Double Sample Rate", variable=Two_X_Sample, command=SetADC_Mux )
23166  twoX.grid(row=1, column=0, sticky=W)
23167  muxlab1 = Label(frame1, text="ADC MUX Modes", style="A10B.TLabel") #, font = "Arial 10 bold")
23168  muxlab1.grid(row=2, column=0, sticky=W)
23169  AltSweep = Checkbutton(frame1, text="Alternate Sweep Mode", variable=Alternate_Sweep_Mode ) #, command=SetADC_Mux )
23170  AltSweep.grid(row=3, column=0, sticky=W)
23171  chabuttons = Frame( frame1 )
23172  chabuttons.grid(row=4, column=0, sticky=W)
23173  muxrb1 = Radiobutton(chabuttons, text="VA and VB", variable=ADC_Mux_Mode, value=0, command=SetADC_Mux ) #style="W8.TButton",
23174  muxrb1.pack(side=LEFT)
23175  muxrb2 = Radiobutton(chabuttons, text="IA and IB", variable=ADC_Mux_Mode, value=1, command=SetADC_Mux ) #style="W8.TButton",
23176  muxrb2.pack(side=LEFT)
23177  chcbuttons = Frame( frame1 )
23178  chcbuttons.grid(row=5, column=0, sticky=W)
23179  muxrb5 = Radiobutton(chcbuttons, text="VA and IA", variable=ADC_Mux_Mode, value=4, command=SetADC_Mux ) # style="W8.TButton",
23180  muxrb5.pack(side=LEFT)
23181  muxrb6 = Radiobutton(chcbuttons, text="VB and IB", variable=ADC_Mux_Mode, value=5, command=SetADC_Mux ) # style="W8.TButton",
23182  muxrb6.pack(side=LEFT)
23183  nextrow = 6
23184  if DeBugMode == 1:
23185  chbbuttons = Frame( frame1 )
23186  chbbuttons.grid(row=nextrow, column=0, sticky=W)
23187  muxrb3 = Radiobutton(chbbuttons, text="VA and IB", variable=ADC_Mux_Mode, value=2, command=SetADC_Mux ) # style="W8.TButton",
23188  muxrb3.pack(side=LEFT)
23189  muxrb4 = Radiobutton(chbbuttons, text="VB and IA", variable=ADC_Mux_Mode, value=3, command=SetADC_Mux ) # style="W8.TButton",
23190  muxrb4.pack(side=LEFT)
23191  nextrow = nextrow + 1
23192  #
23193  sratedismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroySampleRate)
23194  sratedismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
23195 #
23196 def DestroySampleRate():
23197  global SampleRatewindow, SampleRateStatus
23198 
23199  SampleRateStatus.set(0)
23200  SampleRatewindow.destroy()
23201 #
23202 #
23203 def onSrateScroll(event):
23204 
23205  #onTextScroll
23206  onSpinBoxScroll(event)
23207  SetSampleRate()
23208 #
23209 def onRetSrate(event):
23210 
23211  SetSampleRate()
23212 #
23213 def SetSampleRate():
23214  global SAMPLErate, BaseSampleRate, AWGSAMPLErate, session, ETSStatus, etssrlab, BaseRatesb
23215  global Two_X_Sample, ADC_Mux_Mode, rtsrlab, RUNstatus
23216 
23217  #
23218  WasRunning = 0
23219  if (RUNstatus.get() == 1):
23220  WasRunning = 1
23221  BStop() # Force Stop loop if running
23222  try:
23223  NewRate = int(BaseRatesb.get())
23224  if NewRate <= 100000: # rate has to be less than or equal to 100,000
23225  BaseSampleRate = NewRate
23226  else:
23227  BaseSampleRate = 100000
23228  BaseRatesb.delete(0,"end")
23229  BaseRatesb.insert(0,BaseSampleRate)
23230  SAMPLErate = BaseSampleRate # Scope sample rate
23231  except:
23232  donothing()
23233  session.configure(sample_rate=BaseSampleRate)
23234  BaseSampleRate = session.sample_rate
23235  #print("Session sample rate: " + str(session.sample_rate), BaseSampleRate)
23236  SAMPLErate = BaseSampleRate # Scope sample rate
23237  #print("Session sample rate: " + str(session.sample_rate), SAMPLErate)
23238  AWGSAMPLErate = BaseSampleRate
23239  if ETSStatus.get() > 0:
23240  SRstring = "RT Sample Rate = " + str(BaseSampleRate)
23241  rtsrlab.config(text=SRstring)
23242  ETSUpdate()
23243  BaseRatesb.delete(0,"end")
23244  BaseRatesb.insert(0,BaseSampleRate)
23245  ReMakeAWGwaves() # remake AWG waveforms for new rate
23246  if (WasRunning == 1):
23247  WasRunning = 0
23248  BStart() # restart loop if was running
23249 #
23250 def onStopfreqScroll(event):
23251  global StopFreqEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
23252 
23253  onTextScroll(event)
23254  try:
23255  StopFrequency = float(StopFreqEntry.get())
23256  except:
23257  StopFreqEntry.delete(0,"end")
23258  StopFreqEntry.insert(0,50000)
23259  StopFrequency = 50000
23260  if FWRevOne > 2.16:
23261  if StopFrequency >= 50000:
23262  Two_X_Sample.set(1)
23263  ADC_Mux_Mode.set(0)
23264  SetADC_Mux()
23265  else:
23266  Two_X_Sample.set(0)
23267  ADC_Mux_Mode.set(0)
23268  SetADC_Mux()
23269 #
23270 def onStopBodeScroll(event):
23271  global StopBodeEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
23272 
23273  onTextScroll(event)
23274  try:
23275  StopFrequency = float(StopBodeEntry.get())
23276  except:
23277  StopBodeEntry.delete(0,"end")
23278  StopBodeEntry.insert(0,20000)
23279  StopFrequency = 20000
23280  if FWRevOne > 2.16:
23281  if StopFrequency >= 20000:
23282  Two_X_Sample.set(1)
23283  ADC_Mux_Mode.set(0)
23284  SetADC_Mux()
23285  else:
23286  Two_X_Sample.set(0)
23287  ADC_Mux_Mode.set(0)
23288  SetADC_Mux()
23289 #
23290 def SetADC_Mux():
23291  global devx, SAMPLErate, BaseSampleRate, Two_X_Sample, ADC_Mux_Mode, CHA, CHB
23292  global v1_adc_conf, i1_adc_conf, v2_adc_conf, i2_adc_conf
23293  global AWGSync, discontloop, session, ADsignal1
23294 
23295  if Two_X_Sample.get() == 1:
23296  if ADC_Mux_Mode.get() == 0: # VA and VB
23297  devx.set_adc_mux(1)
23298  elif ADC_Mux_Mode.get() == 1: # IA and IB
23299  devx.set_adc_mux(2)
23300  elif ADC_Mux_Mode.get() == 2: # VA and IB
23301  # cycle trhough default mux values as starting point
23302  devx.set_adc_mux(2)
23303  # now set new mux values
23304  devx.set_adc_mux(7)
23305  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
23306  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
23307  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
23308  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
23309  time.sleep(0.1)
23310  elif ADC_Mux_Mode.get() == 3: # VB and IA
23311  # cycle trhough default mux values as starting point
23312  # now set new mux values
23313  devx.set_adc_mux(7)
23314  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
23315  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
23316  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
23317  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
23318  time.sleep(0.1)
23319  elif ADC_Mux_Mode.get() == 4: # VA and IA
23320  # cycle trhough default mux values as starting point
23321  devx.set_adc_mux(2)
23322  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
23323  if discontloop > 0:
23324  session.flush()
23325  else:
23326  discontloop = 1
23327  time.sleep(0.01)
23328  BAWGEnab()
23329  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
23330 
23331  else: # running in continuous mode
23332  if session.continuous:
23333  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
23334  # now set new mux values
23335  devx.set_adc_mux(4)
23336  elif ADC_Mux_Mode.get() == 5: # VB and IB
23337  # cycle trhough default mux values as starting point
23338  devx.set_adc_mux(2)
23339  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
23340  if discontloop > 0:
23341  session.flush()
23342  else:
23343  discontloop = 1
23344  time.sleep(0.01)
23345  BAWGEnab()
23346  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
23347 
23348  else: # running in continuous mode
23349  if session.continuous:
23350  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
23351  # now set new mux values
23352  devx.set_adc_mux(5)
23353  SAMPLErate = BaseSampleRate * 2 # set to 2X sample mode
23354  else:
23355  devx.set_adc_mux(0)
23356  SAMPLErate = BaseSampleRate
23357 #
23358 def TraceSelectADC_Mux():
23359  global ADC_Mux_Mode, Alternate_Sweep_Mode, ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
23360 
23361  if ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
23362  ADC_Mux_Mode.set(0) # All four traces
23363  Alternate_Sweep_Mode.set(1)
23364  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 0:
23365  ADC_Mux_Mode.set(0) # three traces
23366  Alternate_Sweep_Mode.set(1)
23367  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
23368  ADC_Mux_Mode.set(0) # three traces
23369  Alternate_Sweep_Mode.set(1)
23370  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
23371  ADC_Mux_Mode.set(0) # three traces
23372  Alternate_Sweep_Mode.set(1)
23373  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
23374  ADC_Mux_Mode.set(0) # three traces
23375  Alternate_Sweep_Mode.set(1)
23376  #
23377  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
23378  ADC_Mux_Mode.set(1) # IA and IB
23379  Alternate_Sweep_Mode.set(0)
23380  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
23381  ADC_Mux_Mode.set(1) # just IA
23382  Alternate_Sweep_Mode.set(0)
23383  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
23384  ADC_Mux_Mode.set(1) # just IB
23385  Alternate_Sweep_Mode.set(0)
23386  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
23387  ADC_Mux_Mode.set(4) # VA and IA
23388  Alternate_Sweep_Mode.set(0)
23389  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
23390  ADC_Mux_Mode.set(5) # VB and IB
23391  Alternate_Sweep_Mode.set(0)
23392  else:
23393  ADC_Mux_Mode.set(0)
23394  Alternate_Sweep_Mode.set(0)
23395  SetADC_Mux()
23396  UpdateTimeTrace()
23397 #
23398 def UpdateFirmware():
23399  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples
23400  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
23401 
23402  RUNstatus.set(0)
23403  if askyesno("Update current firmware","Flash new firmware to current device:\n(Yes) or (No)?"):
23404  filename = askopenfilename(defaultextension = ".bin", filetypes=[("Binary", "*.bin")])
23405  print( filename)
23406  #print DevID
23407  #print FWRevOne, HWRevOne # devx.fwver, devx.hwver
23408  try:
23409  print( "Cancel current session.")
23410  session.cancel()
23411  print( session.cancelled)
23412  session.end()
23413  print( "Waiting 5...")
23414  time.sleep(5)
23415  print( "Put board in Samba mode and flash firmware.")
23416  session.flash_firmware(filename)
23417  except:
23418  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
23419 
23427  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
23428  showwarning("Exit ALICE","Must Exit Program: \n Restart ALICE to continue.")
23429  Bcloseexit()
23430 
23439 def MakeOhmWindow():
23440  global OhmDisp, OhmStatus, ohmwindow, RevDate, RMode, OhmA0, OhmA1, OhmRunStatus
23441  global CHATestVEntry, CHATestREntry, SWRev, AWGSync, OnBoardRes
23442  global FrameRefief, BorderSize
23443 
23444  if OhmStatus.get() == 0:
23445  AWGSync.set(1)
23446  OhmStatus.set(1)
23447  OhmDisp.set(1)
23448  OhmCheckBox()
23449  ohmwindow = Toplevel()
23450  ohmwindow.title("DC Ohmmeter " + SWRev + RevDate)
23451  ohmwindow.resizable(FALSE,FALSE)
23452  ohmwindow.protocol("WM_DELETE_WINDOW", DestroyOhmScreen)
23453  frame1 = Frame(ohmwindow, borderwidth=BorderSize, relief=FrameRefief)
23454  frame1.grid(row=0, column=0, sticky=W)
23455  #
23456  buttons = Frame( frame1 )
23457  buttons.grid(row=0, column=0, sticky=W)
23458  omrb2 = Radiobutton(buttons, text="Run", style="Run.TRadiobutton", variable=OhmRunStatus, value=1, command=BStartOhm )
23459  omrb2.pack(side=LEFT)
23460  omrb1 = Radiobutton(buttons, text="Stop", style="Stop.TRadiobutton", variable=OhmRunStatus, value=0, command=BStop )
23461  omrb1.pack(side=LEFT)
23462  #
23463  OhmA0 = Label(frame1, style="A16B.TLabel") # , font = "Arial 16 bold")
23464  OhmA0.grid(row=1, column=0, columnspan=2, sticky=W)
23465  OhmA0.config(text = "0.000 Ohms")
23466 
23467  OhmA1 = Label(frame1, style="A12B.TLabel") #, font = "Arial 12 bold")
23468  OhmA1.grid(row=2, column=0, columnspan=2, sticky=W)
23469  OhmA1.config(text = "Meas 0.00 mA 0.00 V")
23470  #
23471  TestVA = Frame( frame1 )
23472  TestVA.grid(row=3, column=0, sticky=W)
23473  chatestvlab = Label(TestVA, text="Test Voltage", style="A10B.TLabel") #, font = "Arial 10 bold")
23474  chatestvlab.pack(side=LEFT)
23475  CHATestVEntry = Entry(TestVA, width=6, cursor='double_arrow') #
23476  CHATestVEntry.pack(side=LEFT)
23477  CHATestVEntry.bind('<MouseWheel>', onTextScroll)
23478  CHATestVEntry.bind("<Button-4>", onTextScroll)# with Linux OS
23479  CHATestVEntry.bind("<Button-5>", onTextScroll)
23480  CHATestVEntry.delete(0,"end")
23481  CHATestVEntry.insert(0,5.0)
23482  #
23483  RMode = IntVar(0)
23484  RMode.set(1)
23485  TestMode = Frame( frame1 )
23486  TestMode.grid(row=4, column=0, sticky=W)
23487  modelab = Label(TestMode, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
23488  modelab.pack(side=LEFT)
23489  rm3 = Radiobutton(TestMode, text="Ext", variable=RMode, value=0)
23490  rm3.pack(side=LEFT)
23491  rm4 = Radiobutton(TestMode, text="Int", variable=RMode, value=1)
23492  rm4.pack(side=LEFT)
23493  #
23494  TestRA = Frame( frame1 )
23495  TestRA.grid(row=5, column=0, sticky=W)
23496  chatestrlab = Label(TestRA, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
23497  chatestrlab.pack(side=LEFT)
23498  CHATestREntry = Entry(TestRA, width=6, cursor='double_arrow') #
23499  CHATestREntry.pack(side=LEFT)
23500  CHATestREntry.bind('<MouseWheel>', onTextScroll)
23501  CHATestREntry.bind("<Button-4>", onTextScroll)# with Linux OS
23502  CHATestREntry.bind("<Button-5>", onTextScroll)
23503  CHATestREntry.delete(0,"end")
23504  CHATestREntry.insert(0,OnBoardRes)
23505  #
23506  ohmdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOhmScreen)
23507  ohmdismissclbutton.grid(row=6, column=0, sticky=W, pady=7)
23508 #
23509 def DestroyOhmScreen():
23510  global ohmwindow, OhmStatus, OhmDisp
23511 
23512  OhmStatus.set(0)
23513  OhmDisp.set(0)
23514  OhmCheckBox()
23515  ohmwindow.destroy()
23516 #
23517 #
23518 # Converts User input string with "M" or "k" to floating point number
23519 # So calculations can be done on the user inputs
23520 def UnitConvert(Value):
23521 
23522  Value = Value.upper()
23523  if 'K' in Value:
23524  Value = str.strip(Value,'K') #
23525  Value = float(Value) * math.pow(10,3)
23526  elif 'M' in Value:
23527  Value = str.strip(Value,'M') #
23528  Value = float(Value) * math.pow(10,6)
23529  else:
23530  Value = float(Value)
23531  return Value
23532 #
23533 # Calculate resistor divider gain and offset voltage
23534 def RDbutton():
23535  global Rint, RDX0L, display9, display8, Voff, R1, R2, resdivwindow
23536  global RDGain, RDOffset, RDeffective
23537  #
23538  try:
23539  X = UnitConvert(Voff.get())
23540  Y = UnitConvert(R1.get())
23541  Z = UnitConvert(R2.get())
23542  ZE = (Z * Rint) / (Z + Rint)
23543  YE = (Y * Rint) / (Y + Rint)
23544  RDGain = (Y + ZE) / ZE
23545  RDOffset = (X * YE)/(YE + Z)
23546  RDeffective = (Y * ZE) / (Y + ZE)
23547  except:
23548  RDOffset = None
23549  RDGain = None
23550  X = None
23551  Y = None
23552  Z = None
23553 
23554  if ((RDOffset is None) or (X is None) or (Y is None) or (Z is None) or (RDGain is None)):
23555  display = Label(resdivwindow, text="Calculation Error", foreground = "Red").place(x = RDX0L+80, y = 260)
23556  else:
23557  display = Label(resdivwindow, text="Calculation Successful", foreground = "Dark Green").place(x = RDX0L+80, y = 260)
23558  display9.config(text="%f Offset" %RDOffset)
23559  display8.config(text="%f Gain" %RDGain)
23560 #
23561 # Draw a resistor shape at location
23562 def DrawRes(X, Y):
23563  global Sche, COLORblack
23564 
23565  ResW = 10
23566  Sche.create_line(X, Y, X, Y+20, fill=COLORblack, width=3)
23567  Sche.create_line(X, Y+20, X+ResW, Y+25, fill=COLORblack, width=3)
23568  Sche.create_line(X+ResW, Y+25, X-ResW, Y+35, fill=COLORblack, width=3)
23569  Sche.create_line(X-ResW, Y+35, X+ResW, Y+45, fill=COLORblack, width=3)
23570  Sche.create_line(X+ResW, Y+45, X-ResW, Y+55, fill=COLORblack, width=3)
23571  Sche.create_line(X-ResW, Y+55, X, Y+60, fill=COLORblack, width=3)
23572  Sche.create_line(X, Y+60, X, Y+80, fill=COLORblack, width=3)
23573 #
23574 def RDSetAGO():
23575  global CHAVGainEntry, CHAVOffsetEntry
23576  global RDGain, RDOffset, CHAIleak, RDeffective
23577 
23578  DivOffset = RDOffset + (CHAIleak * RDeffective)
23579  Gain_str = '{0:.3f}'.format(RDGain)
23580  Voff_str = '{0:.3f}'.format(DivOffset)
23581  CHAVGainEntry.delete(0,"end")
23582  CHAVGainEntry.insert(0,Gain_str)
23583  CHAVOffsetEntry.delete(0,"end")
23584  CHAVOffsetEntry.insert(0,Voff_str)
23585 #
23586 def RDSetBGO():
23587  global CHBVGainEntry, CHBVOffsetEntry
23588  global RDGain, RDOffset, CHBIleak, RDeffective
23589 
23590  DivOffset = RDOffset + (CHBIleak * RDeffective)
23591  Gain_str = '{0:.3f}'.format(RDGain)
23592  Voff_str = '{0:.3f}'.format(DivOffset)
23593  CHBVGainEntry.delete(0,"end")
23594  CHBVGainEntry.insert(0,Gain_str)
23595  CHBVOffsetEntry.delete(0,"end")
23596  CHBVOffsetEntry.insert(0,Voff_str)
23597 #
23599  global SWRev, RevDate, ResDivStatus, ResDivDisp, R1, R2, Voff, COLORblack, COLORwhite
23600  global display8, display9, Sche, resdivwindow, RDGRW, RDGRH, RDY0T, RDX0L
23601 
23602  if ResDivStatus.get() == 0:
23603  ResDivStatus.set(1)
23604  ResDivDisp.set(1)
23605  resdivwindow = Toplevel()
23606  resdivwindow.title("Input Resistor Divider " + SWRev + RevDate)
23607  resdivwindow.resizable(FALSE,FALSE)
23608  resdivwindow.protocol("WM_DELETE_WINDOW", DestroyResDivScreen)
23609  resdivwindow.geometry("530x310")
23610 # from here down we build GUI
23611  Font_tuple = ("Comic Sans MS", 10, "bold")
23612  #
23613  display = Label(resdivwindow, text="M1k Input Resistor Divider", foreground= "Blue",font = Font_tuple)
23614  display.place(x = RDX0L, y = RDY0T)
23615 
23616  display1 = Label(resdivwindow, text="Resistor - R1")
23617  display1.place(x = RDX0L, y = 60)
23618  display2 = Entry(resdivwindow,textvariable=R1)
23619  display2.place(x = RDX0L+80, y = 60)
23620 
23621  display3 = Label(resdivwindow, text="Resistor - R2")
23622  display3.place(x = RDX0L, y = 100)
23623  display4 = Entry(resdivwindow,textvariable=R2)
23624  display4.place(x = RDX0L+80, y = 100)
23625 
23626  display5 = Label(resdivwindow, text="Offset Voltage")
23627  display5.place(x = RDX0L, y = 140)
23628  display6 = Entry(resdivwindow,textvariable=Voff)
23629  display6.place(x = RDX0L+80, y = 140)
23630 
23631  display7 = Label(resdivwindow, text="Divider Offset")
23632  display7.place(x = RDX0L, y = 180)
23633 
23634  display9 = Label(resdivwindow, text="To be calculated", foreground = "Blue")
23635  display9.place(x = RDX0L+80, y = 180)
23636 
23637  display10 = Label(resdivwindow, text="Divider Gain")
23638  display10.place(x = RDX0L, y = 220)
23639 
23640  display8 = Label(resdivwindow, text="To be calculated", foreground = "Blue")
23641  display8.place(x = RDX0L+80, y = 220)
23642 
23643  Calbutton = Button(resdivwindow, text = "Calculate", command=RDbutton)
23644  Calbutton.place(x = RDX0L, y = 260)
23645 
23646  ResDivdismissbutton = Button(resdivwindow, text="Dismiss", command=DestroyResDivScreen)
23647  ResDivdismissbutton.place(x = 230, y = 260)
23648 
23649  ResDivCHAsetbutton = Button(resdivwindow, text="Set CH A", command=RDSetAGO)
23650  ResDivCHAsetbutton.place(x = 330, y = 260)
23651 
23652  ResDivCHBsetbutton = Button(resdivwindow, text="Set CH B", command=RDSetBGO)
23653  ResDivCHBsetbutton.place(x = 430, y = 260)
23654 
23655  Sche = Canvas(resdivwindow, width=RDGRW, height=RDGRH, background=COLORwhite)
23656  Sche.place(x = 230, y = RDY0T) #
23657 
23658  # Draw Schematic
23659  DrawRes(115, 40)
23660  Sche.create_text(140, 80, text = "R1", fill=COLORblack, font=("arial", FontSize+4 ))
23661  DrawRes(115, 120)
23662  Sche.create_text(140, 160, text = "R2", fill=COLORblack, font=("arial", FontSize+4 ))
23663  DrawRes(190, 120)
23664  Sche.create_text(220, 160, text = "Rint", fill=COLORblack, font=("arial", FontSize+4 ))
23665  Sche.create_text(225, 180, text = "1 Meg", fill=COLORblack, font=("arial", FontSize+4 ))
23666  Sche.create_line(70, 40, 115, 40, fill=COLORblack, width=3)
23667  Sche.create_line(70, 200, 115, 200, fill=COLORblack, width=3)
23668  Sche.create_line(115, 120, 235, 120, fill=COLORblack, width=3)
23669  Sche.create_line(175, 200, 205, 200, fill=COLORblack, width=3)
23670  Sche.create_line(175, 200, 190, 220, fill=COLORblack, width=3)
23671  Sche.create_line(205, 200, 190, 220, fill=COLORblack, width=3)
23672  Sche.create_rectangle(40, 30, 70, 50, width=3) #
23673  Sche.create_text(45, 15, text = "V Input", fill=COLORblack, font=("arial", FontSize+4 ))
23674  Sche.create_rectangle(40, 190, 70, 210, width=3) #
23675  Sche.create_text(47, 175, text = "V Offset", fill=COLORblack, font=("arial", FontSize+4 ))
23676  Sche.create_rectangle(235, 110, 265, 130, width=3) #
23677  Sche.create_text(235, 95, text = "M1k Input", fill=COLORblack, font=("arial", FontSize+4 ))
23678 #
23680  global resdivwindow, ResDivStatus, ResDivDisp
23681 
23682  ResDivStatus.set(0)
23683  ResDivDisp.set(0)
23684  resdivwindow.destroy()
23685 #
23686 #
23687 def MakeETSWindow():
23688  global FMulXEntry, MulXEntry, etswindow, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate
23689  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, enb1, rtsrlab, etssrlab, RevDate, SWRev
23690  global MinigenScreenStatus, DeBugMode
23691  global FrameRefief, BorderSize
23692 
23693  #
23694  if ETSStatus.get() == 0:
23695  BaseFreq = (-10, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100)
23696  ETSStatus.set(1)
23697  ETSDisp.set(0)
23698  etswindow = Toplevel()
23699  etswindow.title("ETS Controls " + SWRev + RevDate)
23700  etswindow.resizable(FALSE,FALSE)
23701  etswindow.protocol("WM_DELETE_WINDOW", DestroyETSScreen)
23702  frame1 = Frame(etswindow, borderwidth=BorderSize, relief=FrameRefief)
23703  frame1.grid(row=0, column=0, sticky=W)
23704  # Sampling controls Widgets
23705  SRstring = "RT Sample Rate = " + str(SAMPLErate)
23706  rtsrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
23707  rtsrlab.grid(row=1, column=0, sticky=W)
23708  ESRstring = "ET Sample Rate = " + str(SAMPLErate)
23709  etssrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
23710  etssrlab.grid(row=2, column=0, sticky=W)
23711  etssrbutton = Button(frame1, text="Set RT Sample Rate", command=MakeSampleRateMenu) #, style= "W8.TButton"
23712  etssrbutton.grid(row=3, column=0, sticky=W, pady=7)
23713  enb1 = Checkbutton(frame1,text="Enable ETS", variable=ETSDisp, command=ETSCheckBox)
23714  enb1.grid(row=4, column=0, sticky=W)
23715  #
23716  Divx = Frame( frame1 )
23717  Divx.grid(row=5, column=0, sticky=W)
23718  DivXEntry = Entry(Divx, width=6, cursor='double_arrow')
23719  DivXEntry.bind('<MouseWheel>', ETSscroll)
23720  DivXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
23721  DivXEntry.bind("<Button-5>", ETSscroll)
23722  DivXEntry.pack(side=RIGHT)
23723  DivXEntry.delete(0,"end")
23724  DivXEntry.insert(0,2)
23725  divxlab = Label( Divx, text = "Divide Factor")
23726  divxlab.pack(side=RIGHT)
23727  GridRow = 5
23728  #
23729  if DeBugMode > 0:
23730  FOffEntry = Label(frame1, text="Samples")
23731  FOffEntry.grid(row=GridRow+1, column=0, sticky=W)
23732  MulXEntry = Label( frame1, text = "Rec Len Mul")
23733  MulXEntry.grid(row=GridRow+2, column=0, sticky=W)
23734  GridRow = GridRow + 2
23735  #
23736  eqivsamplerate = Label(frame1, text="MHz", style= "A10B.TLabel")
23737  eqivsamplerate.grid(row=GridRow+1, column=0, sticky=W)
23738  #
23739  FConv = Frame( frame1 )
23740  FConv.grid(row=GridRow+2, column=0, sticky=W)
23741  FMulXEntry = Entry(FConv, width=3, cursor='double_arrow')
23742  FMulXEntry.bind('<MouseWheel>', ETSscroll)
23743  FMulXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
23744  FMulXEntry.bind("<Button-5>", ETSscroll)
23745  FMulXEntry.pack(side=RIGHT)
23746  FMulXEntry.delete(0,"end")
23747  FMulXEntry.insert(0,1)
23748  fminlab = Label( FConv, text = "Freq Multiplier")
23749  fminlab.pack(side=RIGHT)
23750  #
23751  FminDisp = Label(frame1, text="32768 Hz", style= "A10B.TLabel")
23752  FminDisp.grid(row=GridRow+3, column=0, sticky=W)
23753  #
23754  if MinigenScreenStatus.get() > 0:
23755  mgloadbutton = Button(frame1, text="Load to MinGen", command=MGLoad)
23756  mgloadbutton.grid(row=GridRow+4, column=0, sticky=W)
23757  GridRow = GridRow + 1
23758  #
23759  dirlab = Label(frame1, text="Sample Data Order", style= "A10B.TLabel")
23760  dirlab.grid(row=GridRow+5, column=0, sticky=W)
23761  DataMode = Frame( frame1 )
23762  DataMode.grid(row=GridRow+6, column=0, sticky=W)
23763  dm3 = Radiobutton(DataMode, text="Forward", variable=ETSDir, value=0)
23764  dm3.pack(side=LEFT)
23765  dm4 = Radiobutton(DataMode, text="Reverse", variable=ETSDir, value=1)
23766  dm4.pack(side=LEFT)
23767  tclab = Label(frame1, text="CH B Time Shift", style= "A10B.TLabel")
23768  tclab.grid(row=GridRow+7, column=0, sticky=W)
23769  TSMode = Frame( frame1 )
23770  TSMode.grid(row=GridRow+8, column=0, sticky=W)
23771  ETSts = Entry(TSMode, width=6, cursor='double_arrow')
23772  ETSts.bind('<MouseWheel>', ETSscroll)
23773  ETSts.bind("<Button-4>", ETSscroll)# with Linux OS
23774  ETSts.bind("<Button-5>", ETSscroll)
23775  ETSts.pack(side=RIGHT)
23776  ETSts.delete(0,"end")
23777  ETSts.insert(0,1)
23778  ETStslab = Label( TSMode, text = "Factor")
23779  ETStslab.pack(side=RIGHT)
23780  #
23781  etsdismissclbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroyETSScreen)
23782  etsdismissclbutton.grid(row=GridRow+9, column=0, sticky=W, pady=7)
23783  ETSDisp.set(0)
23784  ETSCheckBox()
23785 #
23786 def DestroyETSScreen():
23787  global etswindow, ETSStatus, ETSDisp
23788 
23789  ETSStatus.set(0)
23790  ETSDisp.set(0)
23791  ETSCheckBox()
23792  etswindow.destroy()
23793 #
23794 def MGLoad():
23795  global MinigenFout, Fmin, ETSDir
23796 
23797  MinigenFout.delete(0,"end")
23798  if ETSDir.get() == 0:
23799  MinigenFout.insert(0,Fmin+20)
23800  else:
23801  MinigenFout.insert(0,Fmin-20)
23802  BSendMG()
23803 #
23804 def ETSscroll(event):
23805  onTextScroll(event)
23806  ETSUpdate()
23807 #
23808 def onFminScroll(event):
23809  onTextScroll(event)
23810  ETSUpdate()
23811  SetETSComp()
23812  SetAD9833(event)
23813 
23814 def onMulXScroll(event):
23815  global Two_X_Sample, HtMulEntry, ETSts, etssrlab, SAMPLErate
23816 
23817  onTextScroll(event)
23818  # ETSUpdate()
23819  try:
23820  TscaleX = float(HtMulEntry.get())
23821  except:
23822  HtMulEntry.delete(0,END)
23823  HtMulEntry.insert(0, 1)
23824  if Two_X_Sample.get() == 0:
23825  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
23826  else:
23827  ToffsetX = 0
23828  ETSts.delete(0,"end")
23829  ETSts.insert(0,ToffsetX)
23830  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
23831  etssrlab.config(text=SRstring)
23832  #
23833  SetETSComp()
23834  SetAD9833(event)
23835 #
23836 def ETSUpdate():
23837  global FMulXEntry, MulXEntry, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate, MaxETSrecord
23838  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, DivX, FOff, MulX, Fmin, FMul, SAMPLErate, TIMEdiv
23839  global FminEntry, HtMulEntry, Two_X_Sample, DeBugMode
23840 
23841  if TIMEdiv > 0.2:
23842  MaxETSrecord = int(SAMPLErate * 10 * TIMEdiv / 1000.0)
23843  else:
23844  MaxETSrecord = int(SAMPLErate * 20 * TIMEdiv / 1000.0)
23845  if (MaxETSrecord*100) > MaxSamples:
23846  MaxETSrecord = MaxSamples / 100
23847  try:
23848  DivX = float(eval(DivXEntry.get()))
23849  if DivX < 2:
23850  DivX = 2
23851  if DivX > 75:
23852  DivX = 75
23853  DivXEntry.delete(0,END)
23854  DivXEntry.insert(0, DivX)
23855  except:
23856  DivXEntry.delete(0,END)
23857  DivXEntry.insert(0, DivX)
23858  #
23859  FOff = 25
23860  MulX = (DivX*SAMPLErate)/(100*FOff)
23861  while MulX > MaxETSrecord:
23862  FOff = FOff + 5
23863  MulX = (DivX*SAMPLErate)/(100*FOff)
23864  FOff = 0 - FOff
23865  if DeBugMode > 0:
23866  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
23867  MulXEntry.config(text = SRstring) # change displayed value
23868  SRstring = "Offset = " + str(FOff) + " samples"
23869  FOffEntry.config(text = SRstring) # change displayed value
23870  baseFreq = SAMPLErate/DivX
23871  try:
23872  FMul = float(eval(FMulXEntry.get()))
23873  if FMul < 1:
23874  FMul = 1
23875  FMulXEntry.delete(0,END)
23876  FMulXEntry.insert(0, int(FMul))
23877  if FMul > 75:
23878  FMul = 75
23879  FMulXEntry.delete(0,END)
23880  FMulXEntry.insert(0, int(FMul))
23881  except:
23882  FMulXEntry.delete(0,END)
23883  FMulXEntry.insert(0, int(FMul))
23884  FreqMin = baseFreq * FMul
23885  SRstring = "Multiplied Freq = " + ' {0:.1f} '.format(FreqMin) + " Hz"
23886  FminDisp.config(text = SRstring) # change displayed value
23887  SRstring = "Base Frequency = " + ' {0:.2f} '.format(baseFreq) + " Hz"
23888  eqivsamplerate.config(text = SRstring) # change displayed value
23889  # calculate time scale multiplication factor
23890  try:
23891  MinFreq = eval(FminEntry.get()) * 1000 # convert KHz to Hz
23892  except:
23893  FminEntry.delete(0,END)
23894  FminEntry.insert(0, 25)
23895  #
23896  try: # catch for divide by zero
23897  TscaleX = int((MinFreq)/(DivX * (MinFreq - FreqMin)))
23898  except:
23899  TscaleX = 1
23900 
23901  if TscaleX > 0:
23902  ETSDir.set(0) # set sample direction to forward if positive
23903  else:
23904  ETSDir.set(1) # set sample direction to reverse if negative
23905  TscaleX = abs(TscaleX)
23906  if Two_X_Sample.get() == 0:
23907  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
23908  else:
23909  ToffsetX = 0
23910  ETSts.delete(0,"end")
23911  ETSts.insert(0,ToffsetX)
23912 
23913  HtMulEntry.delete(0,END)
23914  HtMulEntry.insert(0, TscaleX)
23915  SRstring = "RT Sample Rate = " + str(SAMPLErate)
23916  rtsrlab.config(text=SRstring)
23917  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
23918  etssrlab.config(text=SRstring)
23919 #
23920 def Settingsscroll(event):
23921  onTextScroll(event)
23922  SettingsUpdate()
23923 #
23924 def SettingsTextKey(event):
23925  onTextKey(event)
23926  SettingsUpdate()
23927 #
23928 def MakeSettingsMenu():
23929  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
23930  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
23931  global AWG_Amp_Mode, SWRev, EnableHSsampling, Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
23932  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry, TrgLPFEntry, Trigger_LPF_length
23933  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
23934  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
23935  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23936  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23937  global FrameRefief, BorderSize
23938 
23939  if SettingsStatus.get() == 0:
23940  SettingsStatus.set(1)
23941  Settingswindow = Toplevel()
23942  Settingswindow.title("Settings " + SWRev + RevDate)
23943  Settingswindow.resizable(FALSE,FALSE)
23944  Settingswindow.protocol("WM_DELETE_WINDOW", DestroySettings)
23945  frame1 = Frame(Settingswindow, borderwidth=BorderSize, relief=FrameRefief)
23946  frame1.grid(row=0, column=0, sticky=W)
23947  #
23948  zstlab = Label(frame1, text="FFT Zero Stuffing", style= "A10B.TLabel")
23949  zstlab.grid(row=0, column=0, sticky=W)
23950  zstMode = Frame( frame1 )
23951  zstMode.grid(row=0, column=1, sticky=W)
23952  ZSTuff = Entry(zstMode, width=4, cursor='double_arrow')
23953  ZSTuff.bind("<Return>", SettingsTextKey)
23954  ZSTuff.bind('<MouseWheel>', Settingsscroll)
23955  ZSTuff.bind("<Button-4>", Settingsscroll)# with Linux OS
23956  ZSTuff.bind("<Button-5>", Settingsscroll)
23957  ZSTuff.bind('<Key>', SettingsTextKey)
23958  ZSTuff.pack(side=RIGHT)
23959  ZSTuff.delete(0,"end")
23960  ZSTuff.insert(0,ZEROstuffing.get())
23961  #
23962  Avglab = Label(frame1, text="Number Traces to Average", style= "A10B.TLabel")
23963  Avglab.grid(row=1, column=0, sticky=W)
23964  AvgMode = Frame( frame1 )
23965  AvgMode.grid(row=1, column=1, sticky=W)
23966  TAvg = Entry(AvgMode, width=4, cursor='double_arrow')
23967  TAvg.bind("<Return>", SettingsTextKey)
23968  TAvg.bind('<MouseWheel>', Settingsscroll)
23969  TAvg.bind("<Button-4>", Settingsscroll)# with Linux OS
23970  TAvg.bind("<Button-5>", Settingsscroll)
23971  TAvg.bind('<Key>', SettingsTextKey)
23972  TAvg.pack(side=RIGHT)
23973  TAvg.delete(0,"end")
23974  TAvg.insert(0,TRACEaverage.get())
23975  #
23976  HarMlab = Label(frame1, text="Number of Harmonic Markers", style= "A10B.TLabel")
23977  HarMlab.grid(row=2, column=0, sticky=W)
23978  HarMMode = Frame( frame1 )
23979  HarMMode.grid(row=2, column=1, sticky=W)
23980  HarMon = Entry(HarMMode, width=4, cursor='double_arrow')
23981  HarMon.bind("<Return>", SettingsTextKey)
23982  HarMon.bind('<MouseWheel>', Settingsscroll)
23983  HarMon.bind("<Button-4>", Settingsscroll)# with Linux OS
23984  HarMon.bind("<Button-5>", Settingsscroll)
23985  HarMon.bind('<Key>', SettingsTextKey)
23986  HarMon.pack(side=RIGHT)
23987  HarMon.delete(0,"end")
23988  HarMon.insert(0,HarmonicMarkers.get())
23989  #
23990  Vdivlab = Label(frame1, text="Number Vertical Div (SA, Bode)", style= "A10B.TLabel")
23991  Vdivlab.grid(row=3, column=0, sticky=W)
23992  VdivMode = Frame( frame1 )
23993  VdivMode.grid(row=3, column=1, sticky=W)
23994  VDivE = Entry(VdivMode, width=4, cursor='double_arrow')
23995  VDivE.bind("<Return>", SettingsTextKey)
23996  VDivE.bind('<MouseWheel>', Settingsscroll)
23997  VDivE.bind("<Button-4>", Settingsscroll)# with Linux OS
23998  VDivE.bind("<Button-5>", Settingsscroll)
23999  VDivE.bind('<Key>', SettingsTextKey)
24000  VDivE.pack(side=RIGHT)
24001  VDivE.delete(0,"end")
24002  VDivE.insert(0,Vdiv.get())
24003  #
24004  Twdthlab = Label(frame1, text="Trace Width in Pixels", style= "A10B.TLabel")
24005  Twdthlab.grid(row=4, column=0, sticky=W)
24006  TwdthMode = Frame( frame1 )
24007  TwdthMode.grid(row=4, column=1, sticky=W)
24008  TwdthE = Entry(TwdthMode, width=4, cursor='double_arrow')
24009  TwdthE.bind("<Return>", SettingsTextKey)
24010  TwdthE.bind('<MouseWheel>', Settingsscroll)
24011  TwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
24012  TwdthE.bind("<Button-5>", Settingsscroll)
24013  TwdthE.bind('<Key>', SettingsTextKey)
24014  TwdthE.pack(side=RIGHT)
24015  TwdthE.delete(0,"end")
24016  TwdthE.insert(0,TRACEwidth.get())
24017  #
24018  Gwdthlab = Label(frame1, text="Grid Width in Pixels", style= "A10B.TLabel")
24019  Gwdthlab.grid(row=5, column=0, sticky=W)
24020  GwdthMode = Frame( frame1 )
24021  GwdthMode.grid(row=5, column=1, sticky=W)
24022  GwdthE = Entry(GwdthMode, width=4, cursor='double_arrow')
24023  GwdthE.bind("<Return>", SettingsTextKey)
24024  GwdthE.bind('<MouseWheel>', Settingsscroll)
24025  GwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
24026  GwdthE.bind("<Button-5>", Settingsscroll)
24027  GwdthE.bind('<Key>', SettingsTextKey)
24028  GwdthE.pack(side=RIGHT)
24029  GwdthE.delete(0,"end")
24030  GwdthE.insert(0,GridWidth.get())
24031  #
24032  trglpflab = Label(frame1, text="Trigger LPF Length", style= "A10B.TLabel")
24033  trglpflab.grid(row=6, column=0, sticky=W)
24034  TrgLPFMode = Frame( frame1 )
24035  TrgLPFMode.grid(row=6, column=1, sticky=W)
24036  TrgLPFEntry = Entry(TrgLPFMode, width=4, cursor='double_arrow')
24037  TrgLPFEntry.bind("<Return>", SettingsTextKey)
24038  TrgLPFEntry.bind('<MouseWheel>', Settingsscroll)
24039  TrgLPFEntry.bind("<Button-4>", Settingsscroll)# with Linux OS
24040  TrgLPFEntry.bind("<Button-5>", Settingsscroll)
24041  TrgLPFEntry.bind('<Key>', SettingsTextKey)
24042  TrgLPFEntry.pack(side=RIGHT)
24043  TrgLPFEntry.delete(0,"end")
24044  TrgLPFEntry.insert(0,Trigger_LPF_length.get())
24045  #
24046  AwgAmplrb1 = Radiobutton(frame1, text="AWG Min/Max", variable=AWG_Amp_Mode, value=0, command=UpdateAWGWin)
24047  AwgAmplrb1.grid(row=7, column=0, sticky=W)
24048  AwgAmplrb2 = Radiobutton(frame1, text="AWG Amp/Off ", variable=AWG_Amp_Mode, value=1, command=UpdateAWGWin)
24049  AwgAmplrb2.grid(row=7, column=1, sticky=W)
24050  #
24051  cha_Rcomplab = Label(frame1, text="CHA Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
24052  cha_Rcomplab.grid(row=8, column=0, sticky=W)
24053  cha_RcomplabMode = Frame( frame1 )
24054  cha_RcomplabMode.grid(row=8, column=1, sticky=W)
24055  cha_TC1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
24056  cha_TC1Entry.bind("<Return>", SettingsTextKey)
24057  cha_TC1Entry.bind('<MouseWheel>', Settingsscroll)
24058  cha_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24059  cha_TC1Entry.bind("<Button-5>", Settingsscroll)
24060  cha_TC1Entry.bind('<Key>', SettingsTextKey)
24061  cha_TC1Entry.pack(side=LEFT)
24062  cha_TC1Entry.delete(0,"end")
24063  cha_TC1Entry.insert(0,CHA_TC1.get())
24064  cha_A1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
24065  cha_A1Entry.bind("<Return>", SettingsTextKey)
24066  cha_A1Entry.bind('<MouseWheel>', Settingsscroll)
24067  cha_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24068  cha_A1Entry.bind("<Button-5>", Settingsscroll)
24069  cha_A1Entry.bind('<Key>', SettingsTextKey)
24070  cha_A1Entry.pack(side=LEFT)
24071  cha_A1Entry.delete(0,"end")
24072  cha_A1Entry.insert(0,CHA_A1.get())
24073  #
24074  cha_Ccomplab = Label(frame1, text="CHA Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
24075  cha_Ccomplab.grid(row=9, column=0, sticky=W)
24076  cha_CcomplabMode = Frame( frame1 )
24077  cha_CcomplabMode.grid(row=9, column=1, sticky=W)
24078  cha_TC2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
24079  cha_TC2Entry.bind("<Return>", SettingsTextKey)
24080  cha_TC2Entry.bind('<MouseWheel>', Settingsscroll)
24081  cha_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24082  cha_TC2Entry.bind("<Button-5>", Settingsscroll)
24083  cha_TC2Entry.bind('<Key>', SettingsTextKey)
24084  cha_TC2Entry.pack(side=LEFT)
24085  cha_TC2Entry.delete(0,"end")
24086  cha_TC2Entry.insert(0,CHA_TC2.get())
24087  cha_A2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
24088  cha_A2Entry.bind("<Return>", SettingsTextKey)
24089  cha_A2Entry.bind('<MouseWheel>', Settingsscroll)
24090  cha_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24091  cha_A2Entry.bind("<Button-5>", Settingsscroll)
24092  cha_A2Entry.bind('<Key>', SettingsTextKey)
24093  cha_A2Entry.pack(side=LEFT)
24094  cha_A2Entry.delete(0,"end")
24095  cha_A2Entry.insert(0,CHA_A2.get())
24096  #
24097  chb_Rcomplab = Label(frame1, text="CHB Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
24098  chb_Rcomplab.grid(row=10, column=0, sticky=W)
24099  chb_RcomplabMode = Frame( frame1 )
24100  chb_RcomplabMode.grid(row=10, column=1, sticky=W)
24101  chb_TC1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
24102  chb_TC1Entry.bind("<Return>", SettingsTextKey)
24103  chb_TC1Entry.bind('<MouseWheel>', Settingsscroll)
24104  chb_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24105  chb_TC1Entry.bind("<Button-5>", Settingsscroll)
24106  chb_TC1Entry.bind('<Key>', SettingsTextKey)
24107  chb_TC1Entry.pack(side=LEFT)
24108  chb_TC1Entry.delete(0,"end")
24109  chb_TC1Entry.insert(0,CHB_TC1.get())
24110  chb_A1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
24111  chb_A1Entry.bind("<Return>", SettingsTextKey)
24112  chb_A1Entry.bind('<MouseWheel>', Settingsscroll)
24113  chb_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24114  chb_A1Entry.bind("<Button-5>", Settingsscroll)
24115  chb_A1Entry.bind('<Key>', SettingsTextKey)
24116  chb_A1Entry.pack(side=LEFT)
24117  chb_A1Entry.delete(0,"end")
24118  chb_A1Entry.insert(0,CHB_A1.get())
24119  #
24120  chb_Ccomplab = Label(frame1, text="CHB Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
24121  chb_Ccomplab.grid(row=11, column=0, sticky=W)
24122  chb_CcomplabMode = Frame( frame1 )
24123  chb_CcomplabMode.grid(row=11, column=1, sticky=W)
24124  chb_TC2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
24125  chb_TC2Entry.bind("<Return>", SettingsTextKey)
24126  chb_TC2Entry.bind('<MouseWheel>', Settingsscroll)
24127  chb_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24128  chb_TC2Entry.bind("<Button-5>", Settingsscroll)
24129  chb_TC2Entry.bind('<Key>', SettingsTextKey)
24130  chb_TC2Entry.pack(side=LEFT)
24131  chb_TC2Entry.delete(0,"end")
24132  chb_TC2Entry.insert(0,CHB_TC2.get())
24133  chb_A2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
24134  chb_A2Entry.bind("<Return>", SettingsTextKey)
24135  chb_A2Entry.bind('<MouseWheel>', Settingsscroll)
24136  chb_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24137  chb_A2Entry.bind("<Button-5>", Settingsscroll)
24138  chb_A2Entry.bind('<Key>', SettingsTextKey)
24139  chb_A2Entry.pack(side=LEFT)
24140  chb_A2Entry.delete(0,"end")
24141  chb_A2Entry.insert(0,CHB_A2.get())
24142  #
24143  if EnableHSsampling > 0:
24144  hs_ckb1 = Checkbutton(frame1, text="Auto Set ETS Comp", variable=Auto_ETS_Comp, command=SetETSComp)
24145  hs_ckb1.grid(row=12, column=0, sticky=W)
24146  hs1_Complab = Label(frame1, text="ETS Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
24147  hs1_Complab.grid(row=13, column=0, sticky=W)
24148  hs1_ComplabMode = Frame( frame1 )
24149  hs1_ComplabMode.grid(row=13, column=1, sticky=W)
24150  ets_TC1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
24151  ets_TC1Entry.bind("<Return>", SettingsTextKey)
24152  ets_TC1Entry.bind('<MouseWheel>', Settingsscroll)
24153  ets_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24154  ets_TC1Entry.bind("<Button-5>", Settingsscroll)
24155  ets_TC1Entry.bind('<Key>', SettingsTextKey)
24156  ets_TC1Entry.pack(side=LEFT)
24157  ets_TC1Entry.delete(0,"end")
24158  ets_TC1Entry.insert(0,ETS_TC1.get())
24159  ets_A1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
24160  ets_A1Entry.bind("<Return>", SettingsTextKey)
24161  ets_A1Entry.bind('<MouseWheel>', Settingsscroll)
24162  ets_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24163  ets_A1Entry.bind("<Button-5>", Settingsscroll)
24164  ets_A1Entry.bind('<Key>', SettingsTextKey)
24165  ets_A1Entry.pack(side=LEFT)
24166  ets_A1Entry.delete(0,"end")
24167  ets_A1Entry.insert(0,ETS_A1.get())
24168  #
24169  hs2_Complab = Label(frame1, text="ETS Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
24170  hs2_Complab.grid(row=14, column=0, sticky=W)
24171  hs2_ComplabMode = Frame( frame1 )
24172  hs2_ComplabMode.grid(row=14, column=1, sticky=W)
24173  ets_TC2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
24174  ets_TC2Entry.bind("<Return>", SettingsTextKey)
24175  ets_TC2Entry.bind('<MouseWheel>', Settingsscroll)
24176  ets_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24177  ets_TC2Entry.bind("<Button-5>", Settingsscroll)
24178  ets_TC2Entry.bind('<Key>', SettingsTextKey)
24179  ets_TC2Entry.pack(side=LEFT)
24180  ets_TC2Entry.delete(0,"end")
24181  ets_TC2Entry.insert(0,ETS_TC2.get())
24182  ets_A2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
24183  ets_A2Entry.bind("<Return>", SettingsTextKey)
24184  ets_A2Entry.bind('<MouseWheel>', Settingsscroll)
24185  ets_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
24186  ets_A2Entry.bind("<Button-5>", Settingsscroll)
24187  ets_A2Entry.bind('<Key>', SettingsTextKey)
24188  ets_A2Entry.pack(side=LEFT)
24189  ets_A2Entry.delete(0,"end")
24190  ets_A2Entry.insert(0,ETS_A2.get())
24191  #
24192  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
24193  Settingsdismissbutton.grid(row=15, column=0, sticky=W, pady=7)
24194  else:
24195  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
24196  Settingsdismissbutton.grid(row=12, column=0, sticky=W, pady=7)
24197 #
24198 def SetETSComp():
24199  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
24200  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
24201  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
24202  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
24203  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
24204  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
24205 
24206  if Auto_ETS_Comp.get() == 1:
24207  try:
24208  MulX = float(HtMulEntry.get())
24209  #
24210  Value = float(ets_TC1Entry.get()) * MulX
24211  cha_TC1Entry.delete(0,"end")
24212  cha_TC1Entry.insert(0, Value)
24213  cha_A1Entry.delete(0,"end")
24214  cha_A1Entry.insert(0, ets_A1Entry.get())
24215  chb_TC1Entry.delete(0,"end")
24216  chb_TC1Entry.insert(0, Value)
24217  chb_A1Entry.delete(0,"end")
24218  chb_A1Entry.insert(0, ets_A1Entry.get())
24219  #
24220  Value = float(ets_TC2Entry.get()) * MulX
24221  cha_TC2Entry.delete(0,"end")
24222  cha_TC2Entry.insert(0, Value)
24223  cha_A2Entry.delete(0,"end")
24224  cha_A2Entry.insert(0, ets_A2Entry.get())
24225  chb_TC2Entry.delete(0,"end")
24226  chb_TC2Entry.insert(0, Value)
24227  chb_A2Entry.delete(0,"end")
24228  chb_A2Entry.insert(0, ets_A2Entry.get())
24229  except:
24230  MulX = 1.0
24231 
24232 def UpdateAWGWin():
24233 
24234  UpdateAWGA()
24235  UpdateAWGB()
24236  ReMakeAWGwaves()
24237 
24238 def SettingsUpdate():
24239  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
24240  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
24241  global CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
24242  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, TrgLPFEntry, Trigger_LPF_length
24243  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
24244  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
24245 
24246  try:
24247  GW = int(eval(GwdthE.get()))
24248  if GW < 1:
24249  GW = 1
24250  GwdthE.delete(0,END)
24251  GwdthE.insert(0, int(GW))
24252  if GW > 5:
24253  GW = 5
24254  GwdthE.delete(0,END)
24255  GwdthE.insert(0, int(GW))
24256  except:
24257  GwdthE.delete(0,END)
24258  GwdthE.insert(0, GridWidth.get())
24259  GridWidth.set(GW)
24260  #
24261  try:
24262  T_length = int(eval(TrgLPFEntry.get()))
24263  if T_length < 1:
24264  T_length = 1
24265  TrgLPFEntry.delete(0,END)
24266  TrgLPFEntry.insert(0, int(GW))
24267  if T_length > 100:
24268  T_length = 100
24269  TrgLPFEntry.delete(0,END)
24270  TrgLPFEntry.insert(0, int(GW))
24271  except:
24272  TrgLPFEntry.delete(0,END)
24273  TrgLPFEntry.insert(0, Trigger_LPF_length.get())
24274  Trigger_LPF_length.set(T_length)
24275  #
24276  try:
24277  TW = int(eval(TwdthE.get()))
24278  if TW < 1:
24279  TW = 1
24280  TwdthE.delete(0,END)
24281  TwdthE.insert(0, int(TW))
24282  if TW > 5:
24283  TW = 5
24284  TwdthE.delete(0,END)
24285  TwdthE.insert(0, int(TW))
24286  except:
24287  TwdthE.delete(0,END)
24288  TwdthE.insert(0, TRACEwidth.get())
24289  TRACEwidth.set(TW)
24290  # Number of average sweeps for average mode
24291  try:
24292  TA = int(eval(TAvg.get()))
24293  if TA < 1:
24294  TA = 1
24295  TAvg.delete(0,END)
24296  TAvg.insert(0, int(TA))
24297  if TA > 16:
24298  TA = 16
24299  TAvg.delete(0,END)
24300  TAvg.insert(0, int(TA))
24301  except:
24302  TAvg.delete(0,END)
24303  TAvg.insert(0, TRACEaverage.get())
24304  TRACEaverage.set(TA)
24305  # Number of vertical divisions for spectrum / Bode
24306  try:
24307  VDv = int(eval(VDivE.get()))
24308  if VDv < 1:
24309  VDv = 1
24310  VDivE.delete(0,END)
24311  VDivE.insert(0, int(VDv))
24312  if VDv > 16:
24313  VDv = 16
24314  VDivE.delete(0,END)
24315  VDivE.insert(0, int(VDv))
24316  except:
24317  VDivE.delete(0,END)
24318  VDivE.insert(0, Vdiv.get())
24319  Vdiv.set(VDv)
24320  # number of Harmonic Markers in SA
24321  try:
24322  HM = int(eval(HarMon.get()))
24323  if HM < 1:
24324  HM = 1
24325  HarMon.delete(0,END)
24326  HarMon.insert(0, int(HM))
24327  if HM > 9:
24328  HM =9
24329  HarMon.delete(0,END)
24330  HarMon.insert(0, int(HM))
24331  except:
24332  HarMon.delete(0,END)
24333  HarMon.insert(0, HarmonicMarkers.get())
24334  HarmonicMarkers.set(HM)
24335  # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
24336  try:
24337  ZST = int(eval(ZSTuff.get()))
24338  if ZST < 1:
24339  ZST = 1
24340  ZSTuff.delete(0,END)
24341  ZSTuff.insert(0, int(ZST))
24342  if ZST > 5:
24343  ZST = 5
24344  ZSTuff.delete(0,END)
24345  ZSTuff.insert(0, int(ZST))
24346  except:
24347  ZSTuff.delete(0,END)
24348  ZSTuff.insert(0, ZEROstuffing.get())
24349  ZEROstuffing.set(ZST)
24350 #
24351  try:
24352  TC1A = float(cha_TC1Entry.get())
24353  CHA_TC1.set(TC1A)
24354  if TC1A < 0:
24355  TC1A = 0
24356  cha_TC1Entry.delete(0,END)
24357  cha_TC1Entry.insert(0, TC1A)
24358  except:
24359  cha_TC1Entry.delete(0,END)
24360  cha_TC1Entry.insert(0, CHA_TC1.get())
24361  try:
24362  TC2A = float(cha_TC2Entry.get())
24363  CHA_TC2.set(TC2A)
24364  if TC2A < 0:
24365  TC2A = 0
24366  cha_TC2Entry.delete(0,END)
24367  cha_TC2Entry.insert(0, TC2A)
24368  except:
24369  cha_TC2Entry.delete(0,END)
24370  cha_TC2Entry.insert(0, CHA_TC2.get())
24371  #
24372  try:
24373  Gain1A = float(cha_A1Entry.get())
24374  CHA_A1.set(Gain1A)
24375  except:
24376  cha_A1Entry.delete(0,END)
24377  cha_A1Entry.insert(0, CHA_A1.get())
24378  try:
24379  Gain2A = float(cha_A2Entry.get())
24380  CHA_A2.set(Gain2A)
24381  except:
24382  cha_A2Entry.delete(0,END)
24383  cha_A2Entry.insert(0, CHA_A2.get())
24384  #
24385  try:
24386  TC1B = float(chb_TC1Entry.get())
24387  CHB_TC1.set(TC1B)
24388  if TC1B < 0:
24389  TC1B = 0
24390  chb_TC1Entry.delete(0, END)
24391  chb_TC1Entry.insert(0, TC1B)
24392  except:
24393  chb_TC1Entry.delete(0,END)
24394  chb_TC1Entry.insert(0, CHB_TC1.get())
24395  try:
24396  TC2B = float(chb_TC2Entry.get())
24397  CHB_TC2.set(TC2B)
24398  if TC2B < 0:
24399  TC2B = 0
24400  chb_TC2Entry.delete(0, END)
24401  chb_TC2Entry.insert(0, TC2B)
24402  except:
24403  chb_TC2Entry.delete(0,END)
24404  chb_TC2Entry.insert(0, CHB_TC2.get())
24405  #
24406  try:
24407  Gain1B = float(chb_A1Entry.get())
24408  CHB_A1.set(Gain1B)
24409  except:
24410  chb_A1Entry.delete(0,END)
24411  chb_A1Entry.insert(0, CHB_A1.get())
24412  try:
24413  Gain2B = float(chb_A2Entry.get())
24414  CHB_A2.set(Gain2B)
24415  except:
24416  chb_A2Entry.delete(0,END)
24417  chb_A2Entry.insert(0, CHB_A2.get())
24418  # set ETS base comp
24419  #
24420  SetETSComp()
24421 #
24422 def DestroySettings():
24423  global Settingswindow, SettingsStatus
24424 
24425  SettingsStatus.set(0)
24426  SettingsUpdate()
24427  Settingswindow.destroy()
24428 #
24429 def onCanvasMouse_xy(event):
24430  global MouseX, MouseY, MouseWidget
24431 
24432  MouseWidget = event.widget
24433  MouseX, MouseY = event.x, event.y
24434 #
24435 def BSetFmin():
24436  global FminEntry, CHAfreq
24437 
24438  if CHAfreq > 0:
24439  String = '{0:.3f}'.format(CHAfreq/1000)
24440  FminEntry.delete(0,"end")
24441  FminEntry.insert(0,String)
24442 #
24443 def ReSetAGO():
24444  global CHAVGainEntry, CHAVOffsetEntry
24445 
24446  CHAVGainEntry.delete(0,"end")
24447  CHAVGainEntry.insert(0,1.0)
24448  CHAVOffsetEntry.delete(0,"end")
24449  CHAVOffsetEntry.insert(0,0.0)
24450 #
24451 def ReSetBGO():
24452  global CHBVGainEntry, CHBVOffsetEntry
24453 
24454  CHBVGainEntry.delete(0,"end")
24455  CHBVGainEntry.insert(0,1.0)
24456  CHBVOffsetEntry.delete(0,"end")
24457  CHBVOffsetEntry.insert(0,0.0)
24458 #
24459 def ReSetAIGO():
24460  global CHAIGainEntry, CHAIOffsetEntry
24461 
24462  CHAIGainEntry.delete(0,"end")
24463  CHAIGainEntry.insert(0,1.0)
24464  CHAIOffsetEntry.delete(0,"end")
24465  CHAIOffsetEntry.insert(0,0.0)
24466 #
24467 def ReSetBIGO():
24468  global CHBIGainEntry, CHBIOffsetEntry
24469 
24470  CHBIGainEntry.delete(0,"end")
24471  CHBIGainEntry.insert(0,1.0)
24472  CHBIOffsetEntry.delete(0,"end")
24473  CHBIOffsetEntry.insert(0,0.0)
24474 #
24475 def OpenOtherTools():
24476  global EnablePhaseAnalizer, EnableSpectrumAnalizer, EnableBodePlotter, EnableImpedanceAnalizer
24477  global EnableOhmMeter, OOTphckb, OOTBuildPhAScreen, OOTckb3, OOTBuildSpectrumScreen, OOTckb5, ckb1
24478  global OOTBuildBodeScreen, OOTckb4, OOTBuildIAScreen, OOTckb6, OOTBuildOhmScreen, OOTScreenStatus
24479  global OOTwindow, SWRev, RevDate, BorderSize, FrameRefief, OOTdismissclbutton, EnableDigIO
24480  global EnablePIODACMode, EnableMuxMode, EnableMinigenMode, EnablePmodDA1Mode, EnableDigPotMode, EnableGenericSerialMode
24481  global EnableAD5626SerialMode, EnableDigitalFilter, EnableCommandInterface, EnableMeasureScreen, EnableETSScreen
24482 
24483  if OOTScreenStatus.get() == 0:
24484  OOTScreenStatus.set(1)
24485  OOTwindow = Toplevel()
24486  OOTwindow.title("Instruments " + SWRev + RevDate)
24487  OOTwindow.resizable(FALSE,FALSE)
24488  OOTwindow.protocol("WM_DELETE_WINDOW", DestroyOOTwindow)
24489  frame1 = Frame(OOTwindow, borderwidth=BorderSize, relief=FrameRefief)
24490  frame1.grid(row=0, column=0, sticky=W)
24491  #
24492  nextrow = 1
24493  timebtn = Frame( frame1 )
24494  timebtn.grid(row=nextrow, column=0, sticky=W)
24495  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
24496  ckb1.pack(side=LEFT)
24497  timelab = Label(timebtn, text="Time Plot")
24498  timelab.pack(side=LEFT)
24499  nextrow = nextrow + 1
24500  if EnablePhaseAnalizer > 0:
24501  phasebtn = Frame( frame1 )
24502  phasebtn.grid(row=nextrow, column=0, sticky=W)
24503  OOTphckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
24504  OOTphckb.pack(side=LEFT)
24505  OOTBuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
24506  OOTBuildPhAScreen.pack(side=LEFT)
24507  nextrow = nextrow + 1
24508  #
24509  if EnableSpectrumAnalizer > 0:
24510  freqbtn = Frame( frame1 )
24511  freqbtn.grid(row=nextrow, column=0, sticky=W)
24512  OOTckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
24513  OOTckb3.pack(side=LEFT)
24514  OOTBuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
24515  OOTBuildSpectrumScreen.pack(side=LEFT)
24516  nextrow = nextrow + 1
24517  #
24518  if EnableBodePlotter > 0:
24519  bodebtn = Frame( frame1 )
24520  bodebtn.grid(row=nextrow, column=0, sticky=W)
24521  OOTckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
24522  OOTckb5.pack(side=LEFT)
24523  OOTBuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
24524  OOTBuildBodeScreen.pack(side=LEFT)
24525  nextrow = nextrow + 1
24526  #
24527  if EnableImpedanceAnalizer > 0:
24528  impdbtn = Frame( frame1 )
24529  impdbtn.grid(row=nextrow, column=0, sticky=W)
24530  OOTckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
24531  OOTckb4.pack(side=LEFT)
24532  OOTBuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
24533  OOTBuildIAScreen.pack(side=LEFT)
24534  nextrow = nextrow + 1
24535  #
24536  if EnableOhmMeter > 0:
24537  dcohmbtn = Frame( frame1 )
24538  dcohmbtn.grid(row=nextrow, column=0, sticky=W)
24539  OOTckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
24540  OOTckb6.pack(side=LEFT)
24541  OOTBuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
24542  OOTBuildOhmScreen.pack(side=LEFT)
24543  nextrow = nextrow + 1
24544 
24545  if EnableDigIO > 0:
24546  OOTBuildDigScreen = Button(frame1, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
24547  OOTBuildDigScreen.grid(row=nextrow, column=0, sticky=W)
24548  nextrow = nextrow + 1
24549  # Optional plugin tools
24550  if EnablePIODACMode > 0:
24551  OOTBuildDacScreen = Button(frame1, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
24552  OOTBuildDacScreen.grid(row=nextrow, column=0, sticky=W)
24553  nextrow = nextrow + 1
24554  if EnableMuxMode > 0:
24555  OOTBuildMuxScreen = Button(frame1, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
24556  OOTBuildMuxScreen.grid(row=nextrow, column=0, sticky=W)
24557  nextrow = nextrow + 1
24558  if EnableMinigenMode > 0:
24559  OOTBuildMinigenScreen = Button(frame1, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
24560  OOTBuildMinigenScreen.grid(row=nextrow, column=0, sticky=W)
24561  nextrow = nextrow + 1
24562  if EnablePmodDA1Mode > 0:
24563  OOTBuildDA1Screen = Button(frame1, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
24564  OOTBuildDA1Screen.grid(row=nextrow, column=0, sticky=W)
24565  nextrow = nextrow + 1
24566  if EnableDigPotMode >0:
24567  OOTBuildDigPotScreen = Button(frame1, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
24568  OOTBuildDigPotScreen.grid(row=nextrow, column=0, sticky=W)
24569  nextrow = nextrow + 1
24570  if EnableGenericSerialMode >0:
24571  OOTGenericSerialScreen = Button(frame1, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
24572  OOTGenericSerialScreen.grid(row=nextrow, column=0, sticky=W)
24573  nextrow = nextrow + 1
24574  if EnableAD5626SerialMode >0:
24575  OOTAD5626SerialScreen = Button(frame1, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
24576  OOTAD5626SerialScreen.grid(row=nextrow, column=0, sticky=W)
24577  nextrow = nextrow + 1
24578  if EnableDigitalFilter >0:
24579  OOTDigFiltScreen = Button(frame1, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
24580  OOTDigFiltScreen.grid(row=nextrow, column=0, sticky=W)
24581  nextrow = nextrow + 1
24582  if EnableCommandInterface > 0:
24583  OOTCommandLineScreen = Button(frame1, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
24584  OOTCommandLineScreen.grid(row=nextrow, column=0, sticky=W)
24585  nextrow = nextrow + 1
24586  if EnableMeasureScreen > 0:
24587  OOTMeasureScreen = Button(frame1, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
24588  OOTMeasureScreen.grid(row=nextrow, column=0, sticky=W)
24589  nextrow = nextrow + 1
24590  if EnableETSScreen > 0:
24591  OOTETSScreen = Button(frame1, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
24592  OOTETSScreen.grid(row=nextrow, column=0, sticky=W)
24593  nextrow = nextrow + 1
24594  #
24595  OOTdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOOTwindow)
24596  OOTdismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
24597 #
24598 def DestroyOOTwindow():
24599  global OOTwindow, OOTScreenStatus
24600 
24601  OOTScreenStatus.set(0)
24602  OOTwindow.destroy()
24603 #
24604 # Toggle Dlogger flag
24606  global DlogFile, Dlog_open, dlog
24607 
24608  if dlog.get() == 1:
24609  DlogerOpen_out()
24610  #print("Opening Dlog file")
24611  else:
24612  DlogerClose_out()
24613  #print("Closing Dlog file")
24614 #
24615 # Close file for data logging
24617  global DlogFile, Dlog_open, dlog
24618 
24619  if Dlog_open.get() == 1:
24620  try:
24621  DlogFile.close()
24622  #print("Closing Dlog file")
24623  except:
24624  Dlog_open.set(0)
24625  else:
24626  Dlog_open.set(0)
24627 #
24628 # Open file for data logging
24630  global DlogFile, Dlog_open, dlog, UserALabel, UserBLabel
24631 
24632  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
24633  filename = "DataLogger-" + tme
24634  filename = filename + ".csv"
24635  try:
24636  DlogFile = open(filename, 'a')
24637  except:
24638  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
24639  DlogFile = open(filename, 'a')
24640  DlogFile.write( "Time, " + UserALabel + ", " + UserBLabel + "\n" )
24641  Dlog_open.set(1)
24642 #
24643 
24645 TgInput = IntVar(0) # Trigger Input variable
24646 SingleShot = IntVar(0) # variable for single shot triger
24647 ManualTrigger = IntVar(0) # variable for Manual trigger
24648 AutoLevel = IntVar(0) # variable for Auto Level trigger at mid point
24649 ShowC1_V = IntVar(0) # curves to display variables
24650 TgEdge = IntVar(0) # Trigger edge variable
24651 # Show channels variables
24652 ShowC1_V = IntVar(0) # curves to display variables
24653 ShowC1_I = IntVar(0)
24654 ShowC2_V = IntVar(0)
24655 ShowC2_I = IntVar(0)
24656 ShowAV_I = IntVar(0)
24657 ShowBV_I = IntVar(0)
24658 ShowRA_V = IntVar(0)
24659 ShowRA_I = IntVar(0)
24660 ShowRB_V = IntVar(0)
24661 ShowRB_I = IntVar(0)
24662 ShowMath = IntVar(0)
24663 ShowPB_A = IntVar(0)
24664 ShowPB_B = IntVar(0)
24665 ShowPB_C = IntVar(0)
24666 ShowPB_D = IntVar(0)
24667 # Bode and SA variables
24668 ShowC1_VdB = IntVar(0) # curves to display variables
24669 ShowC1_P = IntVar(0)
24670 ShowC2_VdB = IntVar(0)
24671 ShowC2_P = IntVar(0)
24672 ShowMarker = IntVar(0)
24673 ShowRA_VdB = IntVar(0)
24674 ShowRA_P = IntVar(0)
24675 ShowRB_VdB = IntVar(0)
24676 ShowRB_P = IntVar(0)
24677 ShowMathSA = IntVar(0)
24678 ShowRMath = IntVar(0)
24679 ShowAWGASA = IntVar(0)
24680 ShowAWGBSA = IntVar(0)
24681 HScaleBP = IntVar(0)
24682 HScaleBP.set(1)
24683 #
24684 Show_MathX = IntVar(0)
24685 Show_MathY = IntVar(0)
24686 AutoCenterA = IntVar(0)
24687 AutoCenterB = IntVar(0)
24688 SmoothCurves = IntVar(0)
24689 ZOHold = IntVar(0)
24690 TRACEmodeTime = IntVar(0)
24691 TRACEmodeTime.set(0)
24692 DecimateOption = IntVar(0)
24693 MathTrace = IntVar(0)
24694 # AWG variables
24695 AWGAMode = IntVar(0) # AWG A mode variable
24696 AWGAIOMode = IntVar(0) # AWG A Split I/O mode variable
24697 AWGATerm = IntVar(0) # AWG A termination variable
24698 AWGAShape = IntVar(0) # AWG A Wave shape variable
24699 AWGAPhaseDelay = IntVar(0) #
24700 AWGARepeatFlag = IntVar(0) # AWG A Arb shape repeat flag
24701 AWGABurstFlag = IntVar(0) # AWG A Burst mode flag
24702 AWGBBurstFlag = IntVar(0) # AWG B Burst mode flag
24703 AWGBMode = IntVar(0) # AWG B mode variable
24704 AWGBIOMode = IntVar(0) # AWG B Split I/O mode variable
24705 AWGBTerm = IntVar(0) # AWG B termination variable
24706 AWGBShape = IntVar(0) # AWG B Wave shape variable
24707 AWGBPhaseDelay = IntVar(0) #
24708 AWGBRepeatFlag = IntVar(0) # AWG B Arb shape repeat flag
24709 AWGAMode.set(2)
24710 AWGBMode.set(2)
24711 AWGSync = IntVar(0) # Sync start both AWG channels
24712 AWGSync.set(1)
24713 BisCompA = IntVar(0) # Make Channel B comp of channel A
24714 BisCompA.set(0)
24715 # define vertical measurment variables
24716 MeasDCV1 = IntVar(0)
24717 MeasMinV1 = IntVar(0)
24718 MeasMaxV1 = IntVar(0)
24719 MeasMidV1 = IntVar(0)
24720 MeasPPV1 = IntVar(0)
24721 MeasRMSV1 = IntVar(0)
24722 MeasRMSVA_B = IntVar(0)
24723 MeasDCI1 = IntVar(0)
24724 MeasMinI1 = IntVar(0)
24725 MeasMaxI1 = IntVar(0)
24726 MeasMidI1 = IntVar(0)
24727 MeasPPI1 = IntVar(0)
24728 MeasRMSI1 = IntVar(0)
24729 MeasDiffAB = IntVar(0)
24730 MeasDCV2 = IntVar(0)
24731 MeasMinV2 = IntVar(0)
24732 MeasMaxV2 = IntVar(0)
24733 MeasMidV2 = IntVar(0)
24734 MeasPPV2 = IntVar(0)
24735 MeasRMSV2 = IntVar(0)
24736 MeasDCI2 = IntVar(0)
24737 MeasMinI2 = IntVar(0)
24738 MeasMaxI2 = IntVar(0)
24739 MeasMidI2 = IntVar(0)
24740 MeasPPI2 = IntVar(0)
24741 MeasRMSI2 = IntVar(0)
24742 MeasDiffBA = IntVar(0)
24743 MeasUserA = IntVar(0)
24744 MeasAHW = IntVar(0)
24745 MeasALW = IntVar(0)
24746 MeasADCy = IntVar(0)
24747 MeasAPER = IntVar(0)
24748 MeasAFREQ = IntVar(0)
24749 MeasBHW = IntVar(0)
24750 MeasBLW = IntVar(0)
24751 MeasBDCy = IntVar(0)
24752 MeasBPER = IntVar(0)
24753 MeasBFREQ = IntVar(0)
24754 MeasPhase = IntVar(0)
24755 MeasTopV1 = IntVar(0)
24756 MeasBaseV1 = IntVar(0)
24757 MeasTopV2 = IntVar(0)
24758 MeasBaseV2 = IntVar(0)
24759 MeasUserB = IntVar(0)
24760 MeasDelay = IntVar(0)
24761 TimeDisp = IntVar(0)
24762 TimeDisp.set(1)
24763 XYDisp = IntVar(0)
24764 FreqDisp = IntVar(0)
24765 PhADisp = IntVar(0)
24766 BodeDisp = IntVar(0)
24767 IADisp = IntVar(0)
24768 OhmDisp = IntVar(0)
24769 OOTScreenStatus = IntVar(0)
24770 OOTScreenStatus.set(0)
24771 PhAScreenStatus = IntVar(0)
24772 PhAScreenStatus.set(0)
24773 AppendPhAData = IntVar(0)
24774 AppendPhAData.set(0)
24775 PhAPlotMode = IntVar(0)
24776 PhADatafilename = "PhaseData.csv"
24777 BodeScreenStatus = IntVar(0)
24778 BodeScreenStatus.set(0)
24779 DigScreenStatus = IntVar(0)
24780 DigScreenStatus.set(0)
24781 DacScreenStatus = IntVar(0)
24782 DacScreenStatus.set(0)
24783 MuxScreenStatus = IntVar(0)
24784 MuxScreenStatus.set(0)
24785 MuxEnb = IntVar(0)
24786 MuxSync = IntVar(0)
24787 DualMuxMode = IntVar(0)
24788 ChopMuxMode = IntVar(0)
24789 ChopTrig = IntVar(0)
24790 MinigenScreenStatus = IntVar(0)
24791 MinigenScreenStatus.set(0)
24792 DA1ScreenStatus = IntVar(0)
24793 DA1ScreenStatus.set(0)
24794 DigPotScreenStatus = IntVar(0)
24795 DigPotScreenStatus.set(0)
24796 GenericSerialStatus = IntVar(0)
24797 GenericSerialStatus.set(0)
24798 AD5626SerialStatus = IntVar(0)
24799 AD5626SerialStatus.set(0)
24800 DigFiltStatus = IntVar(0)
24801 DigFiltStatus.set(0)
24802 CommandStatus = IntVar(0)
24803 CommandStatus.set(0)
24804 MeasureStatus = IntVar(0)
24805 MeasureStatus.set(0)
24806 MarkerScale = IntVar(0)
24807 MarkerScale.set(1)
24808 SettingsStatus = IntVar(0)
24809 CHA_RC_HP = IntVar(0)
24810 CHB_RC_HP = IntVar(0)
24811 CHAI_RC_HP = IntVar(0)
24812 CHBI_RC_HP = IntVar(0)
24813 HScale = IntVar(0)
24814 SAVScale = IntVar(0)
24815 SAVPSD = IntVar(0)
24816 SAvertmax = 1.0
24817 SAvertmin = 1.0E-6
24818 dlog = IntVar()
24819 dlog.set(0)
24820 Dlog_open = IntVar()
24821 Dlog_open.set(0)
24822 #
24823 if GUITheme == "Light": # Can be Light or Dark or Blue or LtBlue
24824  FrameBG = "#d7d7d7"
24825  ButtonText = "#000000"
24826 elif GUITheme == "Dark":
24827  FrameBG = "#484848"
24828  ButtonText = "#ffffff"
24829 elif GUITheme == "Blue":
24830  FrameBG = "#242468"
24831  ButtonText = "#d0d0ff"
24832 elif GUITheme == "LtBlue":
24833  FrameBG = "#c0e8ff"
24834  ButtonText = "#000040"
24835 EntryText = "#000000"
24836 BoxColor = "#0000ff" # 100% blue
24837 root.style.configure("TFrame", background=FrameBG, borderwidth=BorderSize)
24838 root.style.configure("TLabelframe", background=FrameBG)
24839 root.style.configure("TLabel", foreground=ButtonText, background=FrameBG, relief=LabRelief)
24840 root.style.configure("TEntry", foreground=EntryText, background=FrameBG, relief=ButRelief) #cursor='sb_v_double_arrow'
24841 root.style.configure("TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
24842 root.style.configure("TRadiobutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
24843 root.style.configure("TButton", foreground=ButtonText, background=FrameBG, highlightcolor=FrameBG, relief=ButRelief)
24844 # define custom buttons and labels
24845 root.style.configure("TSpinbox", arrowsize=SBoxarrow) # 11 only changes things in Python 3
24846 root.style.configure("W3.TButton", width=3, relief=ButRelief)
24847 root.style.configure("W4.TButton", width=4, relief=ButRelief)
24848 root.style.configure("W5.TButton", width=5, relief=ButRelief)
24849 root.style.configure("W6.TButton", width=6, relief=ButRelief)
24850 root.style.configure("W7.TButton", width=7, relief=ButRelief)
24851 root.style.configure("W8.TButton", width=8, relief=ButRelief)
24852 root.style.configure("W9.TButton", width=9, relief=ButRelief)
24853 root.style.configure("W10.TButton", width=10, relief=ButRelief)
24854 root.style.configure("W11.TButton", width=11, relief=ButRelief)
24855 root.style.configure("W16.TButton", width=16, relief=ButRelief)
24856 root.style.configure("W17.TButton", width=17, relief=ButRelief)
24857 root.style.configure("Stop.TButton", background=ButtonRed, foreground="#000000", width=4, relief=ButRelief)
24858 root.style.configure("Run.TButton", background=ButtonGreen, foreground="#000000", width=4, relief=ButRelief)
24859 root.style.configure("Pwr.TButton", background=ButtonGreen, foreground="#000000", width=8, relief=ButRelief)
24860 root.style.configure("PwrOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
24861 root.style.configure("Roll.TButton", background=ButtonGreen, foreground="#000000", width=7, relief=ButRelief)
24862 root.style.configure("RollOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
24863 root.style.configure("RConn.TButton", background=ButtonRed, foreground="#000000", width=5, relief=ButRelief)
24864 root.style.configure("GConn.TButton", background=ButtonGreen, foreground="#000000", width=5, relief=ButRelief)
24865 root.style.configure("Rtrace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=RAISED)
24866 root.style.configure("Strace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=SUNKEN)
24867 root.style.configure("Ctrace1.TButton", background=COLORtrace1, foreground="#000000", relief=ButRelief)
24868 root.style.configure("Rtrace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=RAISED)
24869 root.style.configure("Strace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=SUNKEN)
24870 root.style.configure("Ctrace2.TButton", background=COLORtrace2, foreground="#000000", relief=ButRelief)
24871 root.style.configure("Rtrace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=RAISED)
24872 root.style.configure("Strace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=SUNKEN)
24873 root.style.configure("Ctrace3.TButton", background=COLORtrace3, foreground="#000000", relief=ButRelief)
24874 root.style.configure("Rtrace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=RAISED)
24875 root.style.configure("Strace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=SUNKEN)
24876 root.style.configure("Ctrace4.TButton", background=COLORtrace4, foreground="#000000", relief=ButRelief)
24877 root.style.configure("Rtrace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=RAISED)
24878 root.style.configure("Strace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=SUNKEN)
24879 root.style.configure("Rtrace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=RAISED)
24880 root.style.configure("Strace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=SUNKEN)
24881 root.style.configure("T1W16.TButton", background=COLORtrace1, width=16, relief=ButRelief)
24882 root.style.configure("T2W16.TButton", background=COLORtrace2, width=16, relief=ButRelief)
24883 root.style.configure("T3W16.TButton", background=COLORtrace3, width=16, relief=ButRelief)
24884 root.style.configure("T4W16.TButton", background=COLORtrace4, width=16, relief=ButRelief)
24885 root.style.configure("T5W16.TButton", background=COLORtrace5, width=16, relief=ButRelief)
24886 root.style.configure("T6W16.TButton", background=COLORtrace6, width=16, relief=ButRelief)
24887 root.style.configure("T7W16.TButton", background=COLORtrace7, width=16, relief=ButRelief)
24888 root.style.configure("TR1W16.TButton", background=COLORtraceR1, width=16, relief=ButRelief)
24889 root.style.configure("TR2W16.TButton", background=COLORtraceR2, width=16, relief=ButRelief)
24890 root.style.configure("TR3W16.TButton", background=COLORtraceR3, width=16, relief=ButRelief)
24891 root.style.configure("TR4W16.TButton", background=COLORtraceR4, width=16, relief=ButRelief)
24892 root.style.configure("TR5W16.TButton", background=COLORtraceR5, width=16, relief=ButRelief)
24893 root.style.configure("TR6W16.TButton", background=COLORtraceR6, width=16, relief=ButRelief)
24894 root.style.configure("TR7W16.TButton", background=COLORtraceR7, width=16, relief=ButRelief)
24895 root.style.configure("TGW16.TButton", background=COLORtrigger, width=16, relief=ButRelief)
24896 root.style.configure("ZLW16.TButton", background=COLORzeroline, width=16, relief=ButRelief)
24897 root.style.configure("RGray.TButton", background="#808080", width=7, relief=RAISED)
24898 root.style.configure("SGray.TButton", background="#808080", width=7, relief=SUNKEN)
24899 #
24900 root.style.configure("A10T5.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR5, font=('Arial', 10, 'bold'))
24901 root.style.configure("A10T5.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24902 root.style.configure("A10T6.TLabelframe.Label", background=FrameBG, foreground=COLORtrace6, font=('Arial', 10, 'bold'))
24903 root.style.configure("A10T6.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24904 root.style.configure("A10T7.TLabelframe.Label", background=FrameBG, foreground=COLORtrace7, font=('Arial', 10, 'bold'))
24905 root.style.configure("A10T7.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24906 #
24907 root.style.configure("A10R1.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR1, font=('Arial', 10, 'bold'))
24908 root.style.configure("A10R1.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24909 root.style.configure("A10R2.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR2, font=('Arial', 10, 'bold'))
24910 root.style.configure("A10R2.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24911 root.style.configure("A10.TLabelframe.Label", background=FrameBG, font=('Arial', 10, 'bold'))
24912 root.style.configure("A10.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24913 root.style.configure("A10B.TLabel", foreground=ButtonText, font="Arial 10 bold") # Black text
24914 root.style.configure("A10R.TLabel", foreground=ButtonRed, font="Arial 10 bold") # Red text
24915 root.style.configure("A10G.TLabel", foreground=ButtonGreen, font="Arial 10 bold") # Red text
24916 root.style.configure("A12B.TLabel", foreground=ButtonText, font="Arial 12 bold") # Black text
24917 root.style.configure("A16B.TLabel", foreground=ButtonText, font="Arial 16 bold") # Black text
24918 root.style.configure("Stop.TRadiobutton", background=ButtonRed, indicatorcolor=FrameBG)
24919 root.style.configure("Run.TRadiobutton", background=ButtonGreen, indicatorcolor=FrameBG)
24920 root.style.configure("Disab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonRed)
24921 root.style.configure("Enab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonGreen)
24922 root.style.configure("Strace1.TCheckbutton", background=COLORtrace1, foreground="#000000", indicatorcolor="#ffffff")
24923 root.style.configure("Strace2.TCheckbutton", background=COLORtrace2, foreground="#000000", indicatorcolor="#ffffff")
24924 root.style.configure("Strace3.TCheckbutton", background=COLORtrace3, foreground="#000000", indicatorcolor="#ffffff")
24925 root.style.configure("Strace4.TCheckbutton", background=COLORtrace4, foreground="#000000", indicatorcolor="#ffffff")
24926 root.style.configure("Strace6.TCheckbutton", background=COLORtrace6, foreground="#000000", indicatorcolor="#ffffff")
24927 root.style.configure("Strace7.TCheckbutton", background=COLORtrace7, foreground="#000000", indicatorcolor="#ffffff")
24928 root.style.configure("WPhase.TRadiobutton", width=5, foreground="#000000", background="white", indicatorcolor=("red", "green"))
24929 root.style.configure("GPhase.TRadiobutton", width=5, foreground="#000000", background="gray", indicatorcolor=("red", "green"))
24930 # Create frames
24931 frame2r = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
24932 frame2r.pack(side=RIGHT, fill=BOTH, expand=NO)
24933 
24934 frame1 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
24935 frame1.pack(side=TOP, fill=BOTH, expand=NO)
24936 
24937 frame2 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
24938 frame2.pack(side=TOP, fill=BOTH, expand=YES)
24939 
24940 frame3 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
24941 frame3.pack(side=TOP, fill=BOTH, expand=NO)
24942 # create a pulldown menu
24943 # Trigger signals
24944 Triggermenu = Menubutton(frame1, text="Trigger", style="W7.TButton")
24945 Triggermenu.menu = Menu(Triggermenu, tearoff = 0 )
24946 Triggermenu["menu"] = Triggermenu.menu
24947 Triggermenu.menu.add_radiobutton(label='None', variable=TgInput, value=0)
24948 Triggermenu.menu.add_radiobutton(label='CA-V', variable=TgInput, value=1)
24949 Triggermenu.menu.add_radiobutton(label='CA-I', variable=TgInput, value=2)
24950 Triggermenu.menu.add_radiobutton(label='CB-V', variable=TgInput, value=3)
24951 Triggermenu.menu.add_radiobutton(label='CB-I', variable=TgInput, value=4)
24952 Triggermenu.menu.add_radiobutton(label='CA-V or CB-V', variable=TgInput, value=5)
24953 # Triggermenu.menu.add_radiobutton(label='Alternate A/B', variable=TgInput, value=6)
24954 Triggermenu.menu.add_checkbutton(label='Auto Level', variable=AutoLevel)
24955 Triggermenu.menu.add_checkbutton(label='Low Pass Filter', variable=LPFTrigger)
24956 Triggermenu.menu.add_checkbutton(label='Manual Trgger', variable=ManualTrigger)
24957 Triggermenu.menu.add_checkbutton(label='SingleShot', variable=SingleShot)
24958 Triggermenu.pack(side=LEFT)
24959 #
24960 Edgemenu = Menubutton(frame1, text="Edge", style="W5.TButton")
24961 Edgemenu.menu = Menu(Edgemenu, tearoff = 0 )
24962 Edgemenu["menu"] = Edgemenu.menu
24963 Edgemenu.menu.add_radiobutton(label='Rising (+)', variable=TgEdge, value=0)
24964 Edgemenu.menu.add_radiobutton(label='Falling (-)', variable=TgEdge, value=1)
24965 Edgemenu.pack(side=LEFT)
24966 #
24967 tlab = Label(frame1, text="Trig Level")
24968 tlab.pack(side=LEFT)
24969 TRIGGERentry = Entry(frame1, width=5, cursor='double_arrow')
24970 TRIGGERentry.bind('<MouseWheel>', onTextScroll)
24971 TRIGGERentry.bind("<Button-4>", onTextScroll)# with Linux OS
24972 TRIGGERentry.bind("<Button-5>", onTextScroll)
24973 TRIGGERentry.bind("<Return>", BTriglevel)
24974 TRIGGERentry.bind('<Key>', onTextKey)
24975 TRIGGERentry.pack(side=LEFT)
24976 TRIGGERentry.delete(0,"end")
24977 TRIGGERentry.insert(0,0.0)
24978 #
24979 tgb = Button(frame1, text="50%", style="W4.TButton", command=BTrigger50p)
24980 tgb.pack(side=LEFT)
24981 #
24982 hldlab = Button(frame1, text="Hold Off", style="W8.TButton", command=IncHoldOff)
24983 hldlab.pack(side=LEFT)
24984 HoldOffentry = Entry(frame1, width=4, cursor='double_arrow')
24985 HoldOffentry.bind('<MouseWheel>', onTextScroll)
24986 HoldOffentry.bind("<Button-4>", onTextScroll)# with Linux OS
24987 HoldOffentry.bind("<Button-5>", onTextScroll)
24988 HoldOffentry.bind("<Return>", BHoldOff)
24989 HoldOffentry.bind('<Key>', onTextKey)
24990 HoldOffentry.pack(side=LEFT)
24991 HoldOffentry.delete(0,"end")
24992 HoldOffentry.insert(0,0.0)
24993 #
24994 hozlab = Button(frame1, text="Horz Pos", style="W8.TButton", command=SetTriggerPoss)
24995 hozlab.pack(side=LEFT)
24996 HozPossentry = Entry(frame1, width=4, cursor='double_arrow')
24997 HozPossentry.bind('<MouseWheel>', onTextScroll)
24998 HozPossentry.bind("<Button-4>", onTextScroll)# with Linux OS
24999 HozPossentry.bind("<Button-5>", onTextScroll)
25000 HozPossentry.bind("<Return>", BHozPoss)
25001 HozPossentry.bind('<Key>', onTextKey)
25002 HozPossentry.pack(side=LEFT)
25003 HozPossentry.delete(0,"end")
25004 HozPossentry.insert(0,0.0)
25005 #
25006 bexit = Button(frame1, text="Exit", style="W4.TButton", command=Bcloseexit)
25007 bexit.pack(side=RIGHT)
25008 bstop = Button(frame1, text="Stop", style="Stop.TButton", command=BStop)
25009 bstop.pack(side=RIGHT)
25010 brun = Button(frame1, text="Run", style="Run.TButton", command=BStart)
25011 brun.pack(side=RIGHT)
25012 PwrBt = Button(frame1, text="PWR-ON", style="Pwr.TButton", command=BPower)
25013 PwrBt.pack(side=RIGHT)
25014 # Curves Menu
25015 if EnableScopeOnly == 0:
25016  Showmenu = Menubutton(frame1, text="Curves", style="W7.TButton")
25017 else:
25018  Showmenu = Menubutton(frame1, text="Traces", style="W7.TButton")
25019 Showmenu.menu = Menu(Showmenu, tearoff = 0 )
25020 Showmenu["menu"] = Showmenu.menu
25021 Showmenu.menu.add_command(label="-Show Traces-", foreground="blue", command=donothing)
25022 Showmenu.menu.add_command(label="All", command=BShowCurvesAll)
25023 Showmenu.menu.add_command(label="None", command=BShowCurvesNone)
25024 Showmenu.menu.add_checkbutton(label='CA-V (1)', background=COLORtrace1, variable=ShowC1_V, command=TraceSelectADC_Mux)
25025 Showmenu.menu.add_checkbutton(label='CA-I (3)', background=COLORtrace3, variable=ShowC1_I, command=TraceSelectADC_Mux)
25026 Showmenu.menu.add_checkbutton(label='CB-V (2)', background=COLORtrace2, variable=ShowC2_V, command=TraceSelectADC_Mux)
25027 Showmenu.menu.add_checkbutton(label='CB-I (4)', background=COLORtrace4, variable=ShowC2_I, command=TraceSelectADC_Mux)
25028 Showmenu.menu.add_checkbutton(label='Math-X', background=COLORtrace6, variable=Show_MathX, command=UpdateTimeTrace)
25029 Showmenu.menu.add_checkbutton(label='Math-Y', background=COLORtrace7, variable=Show_MathY, command=UpdateTimeTrace)
25030 Showmenu.menu.add_command(label="-Auto Vert Center-", foreground="blue", command=donothing)
25031 Showmenu.menu.add_checkbutton(label='Center CA-V', variable=AutoCenterA)
25032 Showmenu.menu.add_checkbutton(label='Center CB-V', variable=AutoCenterB)
25033 Showmenu.menu.add_command(label="-Input HP Comp-", foreground="blue", command=donothing)
25034 Showmenu.menu.add_checkbutton(label='Comp CA-V', variable=CHA_RC_HP)
25035 Showmenu.menu.add_checkbutton(label='Comp CB-V', variable=CHB_RC_HP)
25036 if EnableHSsampling > 0:
25037  Showmenu.menu.add_checkbutton(label='Comp CA-I', variable=CHAI_RC_HP)
25038  Showmenu.menu.add_checkbutton(label='Comp CB-I', variable=CHBI_RC_HP)
25039 Showmenu.menu.add_separator()
25040 Showmenu.menu.add_checkbutton(label='RA-V', background=COLORtraceR1, variable=ShowRA_V, command=UpdateTimeTrace)
25041 Showmenu.menu.add_checkbutton(label='RA-I', background=COLORtraceR3, variable=ShowRA_I, command=UpdateTimeTrace)
25042 Showmenu.menu.add_checkbutton(label='RB-V', background=COLORtraceR2, variable=ShowRB_V, command=UpdateTimeTrace)
25043 Showmenu.menu.add_checkbutton(label='RB-I', background=COLORtraceR4, variable=ShowRB_I, command=UpdateTimeTrace)
25044 Showmenu.menu.add_checkbutton(label='RMath', background=COLORtraceR5, variable=ShowMath, command=UpdateTimeTrace)
25045 Showmenu.menu.add_separator()
25046 Showmenu.menu.add_checkbutton(label='T Cursor (t)', variable=ShowTCur, command=UpdateTimeTrace)
25047 Showmenu.menu.add_checkbutton(label='V Cursor (v)', variable=ShowVCur, command=UpdateTimeTrace)
25048 Showmenu.pack(side=RIGHT)
25049 #
25050 if ShowBallonHelp > 0:
25051  Triggermenu_tip = CreateToolTip(Triggermenu, 'Select trigger signal')
25052  Edgemenu_tip = CreateToolTip(Edgemenu, 'Select trigger edge')
25053  tgb_tip = CreateToolTip(tgb, 'Set trigger level to waveform mid point')
25054  hldlab_tip = CreateToolTip(hldlab, 'Increment Hold Off setting by one time division')
25055  hozlab_tip = CreateToolTip(hozlab, 'When triggering, set trigger point to center of screen')
25056  bexit_tip = CreateToolTip(bexit, 'Exit ALICE Desktop')
25057  bstop_tip = CreateToolTip(bstop, 'Stop acquiring data')
25058  brun_tip = CreateToolTip(brun, 'Start acquiring data')
25059  pwrbt_tip = CreateToolTip(PwrBt, 'Toggle ext power supply')
25060  Showmenu_tip = CreateToolTip(Showmenu, 'Select which traces to display')
25061 
25062 # Sampling controls Widgets
25063 if EnableHSsampling > 0:
25064  fminlab2 = Label(frame1, text="KHz")
25065  fminlab2.pack(side=RIGHT)
25066  FminEntry = Entry(frame1, width=6, cursor='double_arrow')
25067  FminEntry.bind('<MouseWheel>', onFminScroll)
25068  FminEntry.bind("<Button-4>", onFminScroll)# with Linux OS
25069  FminEntry.bind("<Button-5>", onFminScroll)
25070  FminEntry.bind("<Return>", SetAD9833)
25071  FminEntry.pack(side=RIGHT)
25072  FminEntry.delete(0,"end")
25073  FminEntry.insert(0,25)
25074  fminlab = Button(frame1, text="Fmin", style="W5.TButton", command=BSetFmin)
25075  fminlab.pack(side=RIGHT)
25076  #
25077  HtMulEntry = Entry(frame1, width=4, cursor='double_arrow')
25078  HtMulEntry.bind('<MouseWheel>', onMulXScroll)
25079  HtMulEntry.bind("<Button-4>", onMulXScroll)# with Linux OS
25080  HtMulEntry.bind("<Button-5>", onMulXScroll)
25081  HtMulEntry.bind("<Return>", SetAD9833)
25082  HtMulEntry.pack(side=RIGHT)
25083  HtMulEntry.delete(0,"end")
25084  HtMulEntry.insert(0,1)
25085  mulxlab = Label( frame1, text = "Mul X")
25086  mulxlab.pack(side=RIGHT)
25087 else:
25088  RollBt = Button(frame1, text="Roll-Off", style="RollOff.TButton", command=BRoll)
25089  RollBt.pack(side=RIGHT)
25090 #
25091 # Time per Div
25092 TMsb = Spinbox(frame1, width=5, values= TMpdiv, cursor='double_arrow', command=BTime)
25093 TMsb.bind('<MouseWheel>', onSpinBoxScroll)
25094 TMsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
25095 TMsb.bind("<Button-5>", onSpinBoxScroll)
25096 TMsb.pack(side=RIGHT)
25097 TMsb.delete(0,"end")
25098 TMsb.insert(0,0.5)
25099 TMlab = Label(frame1, text="Time mS/Div")
25100 TMlab.pack(side=RIGHT)
25101 #
25102 ca = Canvas(frame2, width=CANVASwidth, height=CANVASheight, background=COLORcanvas, cursor='cross')
25103 # add mouse left and right button click to canvas
25104 ca.bind('<Configure>', CAresize)
25105 ca.bind('<1>', onCanvasClickLeft)
25106 ca.bind('<3>', onCanvasClickRight)
25107 ca.bind("<Motion>",onCanvasMouse_xy)
25108 ca.bind("<Up>", onCanvasUpArrow) # DoNothing)
25109 ca.bind("<Down>", onCanvasDownArrow)
25110 ca.bind("<Left>", onCanvasLeftArrow)
25111 ca.bind("<Right>", onCanvasRightArrow)
25112 ca.bind("<space>", onCanvasSpaceBar)
25113 ca.bind("1", onCanvasOne)
25114 ca.bind("2", onCanvasTwo)
25115 ca.bind("3", onCanvasThree)
25116 ca.bind("4", onCanvasFour)
25117 ca.bind("5", onCanvasFive)
25118 ca.bind("6", onCanvasSix)
25119 ca.bind("7", onCanvasSeven)
25120 ca.bind("8", onCanvasEight)
25121 ca.bind("9", onCanvasNine)
25122 ca.bind("0", onCanvasZero)
25123 ca.bind("a", onCanvasAverage)
25124 ca.bind("t", onCanvasShowTcur)
25125 ca.bind("v", onCanvasShowVcur)
25126 ca.bind("s", onCanvasSnap)
25127 ca.bind("+", onCanvasTrising)
25128 ca.bind("-", onCanvasTfalling)
25129 ca.bind('<MouseWheel>', onCanvasClickScroll)
25130 ca.bind("<Button-4>", onCanvasClickScroll)# with Linux OS
25131 ca.bind("<Button-5>", onCanvasClickScroll)
25132 ca.pack(side=TOP, fill=BOTH, expand=YES)
25133 MouseWidget = ca
25134 # right side menu buttons
25135 dropmenu = Frame( frame2r )
25136 dropmenu.pack(side=TOP)
25137 bcon = Button(dropmenu, text="Recon", style="RConn.TButton", command=ConnectDevice)
25138 bcon.pack(side=LEFT, anchor=W)
25139 # File menu
25140 Filemenu = Menubutton(dropmenu, text="File", style="W4.TButton")
25141 Filemenu.menu = Menu(Filemenu, tearoff = 0 )
25142 Filemenu["menu"] = Filemenu.menu
25143 Filemenu.menu.add_command(label="Save Config", command=BSaveConfigTime)
25144 Filemenu.menu.add_command(label="Load Config", command=BLoadConfigTime)
25145 Filemenu.menu.add_command(label="Run Script", command=RunScript)
25146 Filemenu.menu.add_command(label="Save Adj", command=BSaveCal)
25147 Filemenu.menu.add_command(label="Load Adj", command=BLoadCal)
25148 Filemenu.menu.add_command(label="Save Screen", command=BSaveScreen)
25149 Filemenu.menu.add_command(label="Save To CSV", command=BSaveData)
25150 Filemenu.menu.add_command(label="Load From CSV", command=BReadData)
25151 Filemenu.menu.add_command(label="Save PWL Data", command=BSaveChannelData)
25152 Filemenu.menu.add_checkbutton(label="DLog to file", variable=dlog, command=Dloger_on_off)
25153 Filemenu.menu.add_command(label="Help", command=BHelp)
25154 Filemenu.menu.add_command(label="About", command=BAbout)
25155 Filemenu.pack(side=LEFT, anchor=W)
25156 # Options Menu
25157 Optionmenu = Menubutton(dropmenu, text="Options", style="W7.TButton")
25158 Optionmenu.menu = Menu(Optionmenu, tearoff = 0 )
25159 Optionmenu["menu"] = Optionmenu.menu
25160 Optionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
25161 Optionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
25162 Optionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurves, command=UpdateTimeTrace)
25163 Optionmenu.menu.add_checkbutton(label='Z-O-Hold', variable=ZOHold, command=UpdateTimeTrace)
25164 Optionmenu.menu.add_checkbutton(label='Decimate', variable=DecimateOption)
25165 Optionmenu.menu.add_checkbutton(label='Gated Meas', variable=MeasGateStatus)
25166 Optionmenu.menu.add_checkbutton(label='Trace Avg (a)', variable=TRACEmodeTime)
25167 Optionmenu.menu.add_checkbutton(label='Persistance', variable=ScreenTrefresh)
25168 Optionmenu.menu.add_command(label='Set Marker Location', command=BSetMarkerLocation)
25169 Optionmenu.menu.add_command(label='Change Plot Label', command=BUserCustomPlotText)
25170 Optionmenu.menu.add_command(label="SnapShot (s)", command=BSnapShot)
25171 Optionmenu.menu.add_command(label="Color Selector", command=ColorSelector)
25172 Optionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
25173 Optionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
25174 Optionmenu.menu.add_command(label="Run Self Cal", command=SelfCalibration)
25175 if EnableScopeOnly != 0:
25176  Optionmenu.menu.add_command(label="Open Instruments", command=OpenOtherTools)
25177 if AllowFlashFirmware == 1:
25178  Optionmenu.menu.add_command(label="Save Cal Settings", command=Save_Cal_file)
25179  Optionmenu.menu.add_command(label="Update Firmware", command=UpdateFirmware)
25180 Optionmenu.pack(side=LEFT, anchor=W)
25181 #
25182 dropmenu2 = Frame( frame2r )
25183 dropmenu2.pack(side=TOP)
25184 # Open Math trace menu
25185 mathbt = Button(dropmenu2, text="Math", style="W4.TButton", command = NewEnterMathControls)
25186 mathbt.pack(side=RIGHT, anchor=W)
25187 # Measurments menu
25188 measlab = Label(dropmenu2, text="Meas")
25189 measlab.pack(side=LEFT, anchor=W)
25190 MeasmenuA = Menubutton(dropmenu2, text="CA", style="W3.TButton")
25191 MeasmenuA.menu = Menu(MeasmenuA, tearoff = 0 )
25192 MeasmenuA["menu"] = MeasmenuA.menu
25193 MeasmenuA.menu.add_command(label="-CA-V-", foreground="blue", command=donothing)
25194 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCV1)
25195 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinV1)
25196 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxV1)
25197 MeasmenuA.menu.add_checkbutton(label='Base', variable=MeasBaseV1)
25198 MeasmenuA.menu.add_checkbutton(label='Top', variable=MeasTopV1)
25199 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidV1)
25200 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPV1)
25201 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSV1)
25202 MeasmenuA.menu.add_checkbutton(label='CA-CB', variable=MeasDiffAB)
25203 MeasmenuA.menu.add_checkbutton(label='CA-CB RMS', variable=MeasRMSVA_B)
25204 MeasmenuA.menu.add_checkbutton(label='User', variable=MeasUserA, command=BUserAMeas)
25205 #MeasmenuA.menu.add_separator()
25206 MeasmenuA.menu.add_command(label="-CA-I-", foreground="blue", command=donothing)
25207 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCI1)
25208 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinI1)
25209 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxI1)
25210 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidI1)
25211 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPI1)
25212 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSI1)
25213 #MeasmenuA.menu.add_separator()
25214 MeasmenuA.menu.add_command(label="-CA-Time-", foreground="blue", command=donothing)
25215 MeasmenuA.menu.add_checkbutton(label='H-Width', variable=MeasAHW)
25216 MeasmenuA.menu.add_checkbutton(label='L-Width', variable=MeasALW)
25217 MeasmenuA.menu.add_checkbutton(label='DutyCyle', variable=MeasADCy)
25218 MeasmenuA.menu.add_checkbutton(label='Period', variable=MeasAPER)
25219 MeasmenuA.menu.add_checkbutton(label='Freq', variable=MeasAFREQ)
25220 MeasmenuA.menu.add_checkbutton(label='A-B Phase', variable=MeasPhase)
25221 #
25222 MeasmenuA.pack(side=LEFT)
25223 #
25224 MeasmenuB = Menubutton(dropmenu2, text="CB", style="W3.TButton")
25225 MeasmenuB.menu = Menu(MeasmenuB, tearoff = 0 )
25226 MeasmenuB["menu"] = MeasmenuB.menu
25227 MeasmenuB.menu.add_command(label="-CB-V-", foreground="blue", command=donothing)
25228 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCV2)
25229 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinV2)
25230 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxV2)
25231 MeasmenuB.menu.add_checkbutton(label='Base', variable=MeasBaseV2)
25232 MeasmenuB.menu.add_checkbutton(label='Top', variable=MeasTopV2)
25233 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidV2)
25234 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPV2)
25235 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSV2)
25236 MeasmenuB.menu.add_checkbutton(label='CB-CA', variable=MeasDiffBA)
25237 MeasmenuB.menu.add_checkbutton(label='User', variable=MeasUserB, command=BUserBMeas)
25238 #MeasmenuB.menu.add_separator()
25239 MeasmenuB.menu.add_command(label="-CB-I-", foreground="blue", command=donothing)
25240 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCI2)
25241 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinI2)
25242 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxI2)
25243 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidI2)
25244 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPI2)
25245 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSI2)
25246 #MeasmenuB.menu.add_separator()
25247 MeasmenuB.menu.add_command(label="-CB-Time-", foreground="blue", command=donothing)
25248 MeasmenuB.menu.add_checkbutton(label='H-Width', variable=MeasBHW)
25249 MeasmenuB.menu.add_checkbutton(label='L-Width', variable=MeasBLW)
25250 MeasmenuB.menu.add_checkbutton(label='DutyCyle', variable=MeasBDCy)
25251 MeasmenuB.menu.add_checkbutton(label='Period', variable=MeasBPER)
25252 MeasmenuB.menu.add_checkbutton(label='Freq', variable=MeasBFREQ)
25253 MeasmenuB.menu.add_checkbutton(label='B-A Delay', variable=MeasDelay)
25254 MeasmenuB.pack(side=LEFT)
25255 if ShowBallonHelp > 0:
25256  math_tip = CreateToolTip(mathbt, 'Open Math window')
25257  options_tip = CreateToolTip(Optionmenu, 'Select Optional Settings')
25258  file_tip = CreateToolTip(Filemenu, 'Select File operations')
25259 #
25260 DigScreenStatus = IntVar(0)
25261 DigScreenStatus.set(0)
25262 #
25263 if EnableScopeOnly == 0:
25264  BuildAWGScreen = Button(frame2r, text="AWG Window", style="W16.TButton", command=MakeAWGWindow)
25265  BuildAWGScreen.pack(side=TOP)
25266  # Mode selector
25267  timebtn = Frame( frame2r )
25268  timebtn.pack(side=TOP)
25269  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
25270  ckb1.pack(side=LEFT)
25271  timelab = Label(timebtn, text="Time Plot")
25272  timelab.pack(side=LEFT)
25273  if EnableXYPlotter > 0:
25274  xybtn = Frame( frame2r )
25275  xybtn.pack(side=TOP)
25276  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
25277  ckb2.pack(side=LEFT)
25278  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
25279  BuildXYScreen.pack(side=TOP)
25280  #
25281  if EnablePhaseAnalizer > 0:
25282  phasebtn = Frame( frame2r )
25283  phasebtn.pack(side=TOP)
25284  phckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
25285  phckb.pack(side=LEFT)
25286  BuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
25287  BuildPhAScreen.pack(side=LEFT)
25288  #
25289  if EnableSpectrumAnalizer > 0:
25290  freqbtn = Frame( frame2r )
25291  freqbtn.pack(side=TOP)
25292  ckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
25293  ckb3.pack(side=LEFT)
25294  BuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
25295  BuildSpectrumScreen.pack(side=LEFT)
25296  #
25297  if EnableBodePlotter > 0:
25298  bodebtn = Frame( frame2r )
25299  bodebtn.pack(side=TOP)
25300  ckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
25301  ckb5.pack(side=LEFT)
25302  BuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
25303  BuildBodeScreen.pack(side=LEFT)
25304  #
25305  if EnableImpedanceAnalizer > 0:
25306  impdbtn = Frame( frame2r )
25307  impdbtn.pack(side=TOP)
25308  ckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
25309  ckb4.pack(side=LEFT)
25310  BuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
25311  BuildIAScreen.pack(side=LEFT)
25312  #
25313  if EnableOhmMeter > 0:
25314  dcohmbtn = Frame( frame2r )
25315  dcohmbtn.pack(side=TOP)
25316  ckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
25317  ckb6.pack(side=LEFT)
25318  BuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
25319  BuildOhmScreen.pack(side=LEFT)
25320  #
25321  if ShowTraceControls > 0:
25322  Labelfonttext = "Arial " + str(FontSize) + " bold"
25323  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
25324  tracelab.pack(side=TOP)
25325  trctrla = Frame( frame2r )
25326  trctrla.pack(side=TOP)
25327  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
25328  ckbt1.pack(side=LEFT,fill=X)
25329  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
25330  ckbt2.pack(side=LEFT,fill=X)
25331  trctrlb = Frame( frame2r )
25332  trctrlb.pack(side=TOP)
25333  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
25334  ckbt3.pack(side=LEFT,fill=X)
25335  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
25336  ckbt4.pack(side=LEFT,fill=X)
25337 
25338  if ShowBallonHelp > 0:
25339  try:
25340  BuildAWGScreen_tip = CreateToolTip(BuildAWGScreen, 'Surface AWG Controls window')
25341  except:
25342  donothing()
25343  try:
25344  BuildXYScreen_tip = CreateToolTip(BuildXYScreen, 'Open X vs Y plot window')
25345  except:
25346  donothing()
25347  try:
25348  BuildPhAScreen_tip = CreateToolTip(BuildPhAScreen, 'Open Phase Analyzer window')
25349  except:
25350  donothing()
25351  try:
25352  BuildSpectrumScreen_tip = CreateToolTip(BuildSpectrumScreen, 'Open Spectrum Analyzer window')
25353  except:
25354  donothing()
25355  try:
25356  BuildBodeScreen_tip = CreateToolTip(BuildBodeScreen, 'Open Bode plot window')
25357  except:
25358  donothing()
25359  try:
25360  BuildIAScreen_tip = CreateToolTip(BuildIAScreen, 'Open Impedance Analyzer window')
25361  except:
25362  donothing()
25363  try:
25364  BuildOhmScreen_tip = CreateToolTip(BuildOhmScreen, 'Open DC Ohmmeter window')
25365  except:
25366  donothing()
25367  # Digital Input / Output Option screens
25368  if EnableDigIO > 0:
25369  BuildDigScreen = Button(frame2r, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
25370  BuildDigScreen.pack(side=TOP)
25371  # Optional plugin tools
25372  if EnablePIODACMode > 0:
25373  BuildDacScreen = Button(frame2r, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
25374  BuildDacScreen.pack(side=TOP)
25375  if EnableMuxMode > 0:
25376  BuildMuxScreen = Button(frame2r, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
25377  BuildMuxScreen.pack(side=TOP)
25378  if EnableMinigenMode > 0:
25379  BuildMinigenScreen = Button(frame2r, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
25380  BuildMinigenScreen.pack(side=TOP)
25381  if EnablePmodDA1Mode > 0:
25382  BuildDA1Screen = Button(frame2r, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
25383  BuildDA1Screen.pack(side=TOP)
25384  if EnableDigPotMode >0:
25385  BuildDigPotScreen = Button(frame2r, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
25386  BuildDigPotScreen.pack(side=TOP)
25387  if EnableGenericSerialMode >0:
25388  GenericSerialScreen = Button(frame2r, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
25389  GenericSerialScreen.pack(side=TOP)
25390  if EnableAD5626SerialMode >0:
25391  AD5626SerialScreen = Button(frame2r, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
25392  AD5626SerialScreen.pack(side=TOP)
25393  if EnableDigitalFilter >0:
25394  DigFiltScreen = Button(frame2r, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
25395  DigFiltScreen.pack(side=TOP)
25396  if EnableCommandInterface > 0:
25397  CommandLineScreen = Button(frame2r, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
25398  CommandLineScreen.pack(side=TOP)
25399  if EnableMeasureScreen > 0:
25400  MeasureScreen = Button(frame2r, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
25401  MeasureScreen.pack(side=TOP)
25402  if EnableETSScreen > 0:
25403  ETSScreen = Button(frame2r, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
25404  ETSScreen.pack(side=TOP)
25405 else:
25406 # Mode selector
25407  if EnableXYPlotter > 0:
25408  xybtn = Frame( frame2r )
25409  xybtn.pack(side=TOP)
25410  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
25411  ckb2.pack(side=LEFT)
25412  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
25413  BuildXYScreen.pack(side=TOP)
25414  #
25415  if ShowTraceControls > 0:
25416  Labelfonttext = "Arial " + str(FontSize) + " bold"
25417  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
25418  tracelab.pack(side=TOP)
25419  trctrla = Frame( frame2r )
25420  trctrla.pack(side=TOP)
25421  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
25422  ckbt1.pack(side=LEFT,fill=X)
25423  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
25424  ckbt2.pack(side=LEFT,fill=X)
25425  trctrlb = Frame( frame2r )
25426  trctrlb.pack(side=TOP)
25427  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
25428  ckbt3.pack(side=LEFT,fill=X)
25429  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
25430  ckbt4.pack(side=LEFT,fill=X)
25431  #
25432  awg1eb = Frame( frame2r )
25433  awg1eb.pack(side=TOP)
25434  ModeAMenu = Menubutton(awg1eb, text="Mode", width=5, style="Ctrace1.TButton")#, style="W5.TButton")
25435  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
25436  ModeAMenu["menu"] = ModeAMenu.menu
25437  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
25438  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
25439  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
25440  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
25441  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
25442  ModeAMenu.menu.add_separator()
25443  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
25444  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
25445  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
25446  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
25447  ModeAMenu.pack(side=LEFT, anchor=W)
25448  ShapeAMenu = Menubutton(awg1eb, text="Shape", width=6, style="Ctrace1.TButton")#, style="W6.TButton")
25449  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
25450  ShapeAMenu["menu"] = ShapeAMenu.menu
25451  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
25452  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
25453  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
25454  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
25455  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
25456  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
25457  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
25458  if AWGShowAdvanced.get() > 0:
25459  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
25460  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
25461  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
25462  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
25463  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
25464  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
25465  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
25466  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
25467  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
25468  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
25469  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
25470  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
25471  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
25472  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
25473  else:
25474  ShapeAMenu.menu.add_separator()
25475  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
25476  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
25477  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
25478  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
25479  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
25480  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
25481  ShapeAMenu.pack(side=LEFT, anchor=W)
25482  #
25483  awg1model = Frame( frame2r )
25484  awg1model.pack(side=TOP,fill=X) #)
25485  AWGAModeLabel = Label(awg1model, text="AWG A Mode", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
25486  AWGAModeLabel.pack(side=LEFT, fill=X)
25487  AWGAShapeLabel = Label(awg1model, text="AWG A Shape", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
25488  AWGAShapeLabel.pack(side=LEFT, fill=X)
25489  #
25490  awg1ampl = Frame( frame2r )
25491  awg1ampl.pack(side=TOP,fill=X) #)
25492  amp1lab = Label(awg1ampl) #
25493  amp1lab.grid(row=0,column=0,sticky=E+S+N+W)
25494  off1lab = Label(awg1ampl) #
25495  off1lab.grid(row=0,column=1,sticky=E+S+N+W)
25496  freq1lab = Label(awg1ampl, text="Freq")
25497  freq1lab.grid(row=0,column=2,sticky=E+S+N+W)
25498  #
25499  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
25500  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
25501  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
25502  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25503  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
25504  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
25505  AWGAAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
25506  AWGAAmplEntry.delete(0,"end")
25507  AWGAAmplEntry.insert(0,0.0)
25508  #
25509  AWGAOffsetEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
25510  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
25511  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
25512  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25513  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
25514  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
25515  AWGAOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
25516  AWGAOffsetEntry.delete(0,"end")
25517  AWGAOffsetEntry.insert(0,0.0)
25518 
25519  if AWG_Amp_Mode.get() == 0:
25520  amp1lab.config(text = "Min" ) # change displayed value
25521  off1lab.config(text = "Max" ) # change displayed value
25522  else:
25523  amp1lab.config(text = "Amp" )
25524  off1lab.config(text = "Off" )
25525  # AWG Frequency sub frame
25526  AWGAFreqEntry = Entry(awg1ampl, width=7, cursor='double_arrow')
25527  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
25528  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
25529  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25530  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
25531  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
25532  AWGAFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
25533  AWGAFreqEntry.delete(0,"end")
25534  AWGAFreqEntry.insert(0,100.0)
25535  # AWG Phase or delay select sub frame
25536  # AWG Phase entry sub frame
25537  awg1phase = Frame( frame2r )
25538  awg1phase.pack(side=TOP)
25539  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
25540  awgaph.pack(side=LEFT, anchor=W)
25541  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
25542  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
25543  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
25544  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25545  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
25546  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
25547  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
25548  AWGAPhaseEntry.delete(0,"end")
25549  AWGAPhaseEntry.insert(0,0)
25550  phasealab = Label(awg1phase, text="Deg")
25551  phasealab.pack(side=LEFT, anchor=W)
25552  # AWG duty cycle frame
25553  awg1dc = Frame( frame2r )
25554  awg1dc.pack(side=TOP)
25555  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
25556  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
25557  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
25558  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25559  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
25560  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
25561  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
25562  AWGADutyCycleEntry.delete(0,"end")
25563  AWGADutyCycleEntry.insert(0,50)
25564  duty1lab = Label(awg1dc, text="%")
25565  duty1lab.pack(side=LEFT, anchor=W)
25566 
25579  awg2eb = Frame( frame2r )
25580  awg2eb.pack(side=TOP)
25581  ModeBMenu = Menubutton(awg2eb, text="Mode", width=5, style="Ctrace2.TButton")# , style="W5.TButton")
25582  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
25583  ModeBMenu["menu"] = ModeBMenu.menu
25584  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
25585  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
25586  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
25587  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
25588  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
25589  ModeBMenu.menu.add_separator()
25590  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
25591  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
25592  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
25593  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
25594  ModeBMenu.pack(side=LEFT, anchor=W)
25595  ShapeBMenu = Menubutton(awg2eb, text="Shape", width=6, style="Ctrace2.TButton")#, style="W6.TButton")
25596  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
25597  ShapeBMenu["menu"] = ShapeBMenu.menu
25598  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
25599  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
25600  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
25601  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
25602  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
25603  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
25604  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
25605  if AWGShowAdvanced.get() > 0:
25606  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
25607  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
25608  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
25609  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
25610  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
25611  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
25612  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
25613  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
25614  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
25615  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
25616  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
25617  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
25618  else:
25619  ShapeBMenu.menu.add_separator()
25620  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
25621  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
25622  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
25623  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
25624  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
25625  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
25626  ShapeBMenu.pack(side=LEFT, anchor=W)
25627  #
25628  awg2model = Frame( frame2r )
25629  awg2model.pack(side=TOP,fill=X) #)
25630  AWGBModeLabel = Label(awg2model, text="AWG B Mode", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
25631  AWGBModeLabel.pack(side=LEFT, fill=X)
25632  AWGBShapeLabel = Label(awg2model, text="AWG B Shape", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
25633  AWGBShapeLabel.pack(side=LEFT, fill=X)
25634  #
25635  awg2ampl = Frame( frame2r )
25636  awg2ampl.pack(side=TOP)
25637  amp2lab = Label(awg2ampl) #, text="Min Ch B")
25638  amp2lab.grid(row=0,column=0,sticky=E+S+N+W)
25639  #amp2lab.pack(side=LEFT, anchor=W)
25640  off2lab = Label(awg2ampl) #, text="Max Ch B")
25641  off2lab.grid(row=0,column=1,sticky=E+S+N+W)
25642  #off2lab.pack(side=LEFT, anchor=W)
25643  freq2lab = Label(awg2ampl, text="Freq")
25644  freq2lab.grid(row=0,column=2,sticky=E+S+N+W)
25645  # freq2lab.pack(side=LEFT, anchor=W)
25646  #
25647  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
25648  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
25649  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
25650  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25651  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
25652  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
25653  AWGBAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
25654  AWGBAmplEntry.delete(0,"end")
25655  AWGBAmplEntry.insert(0,0.0)
25656  #
25657  AWGBOffsetEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
25658  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
25659  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
25660  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25661  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
25662  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
25663  AWGBOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
25664  AWGBOffsetEntry.delete(0,"end")
25665  AWGBOffsetEntry.insert(0,0.0)
25666 
25667  if AWG_Amp_Mode.get() == 0:
25668  amp2lab.config(text = "Min" ) # change displayed value
25669  off2lab.config(text = "Max" ) # change displayed value
25670  else:
25671  amp2lab.config(text = "Amp" )
25672  off2lab.config(text = "Off" )
25673  # AWG Frequency
25674  AWGBFreqEntry = Entry(awg2ampl, width=7, cursor='double_arrow')
25675  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
25676  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
25677  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25678  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
25679  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
25680  AWGBFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
25681  AWGBFreqEntry.delete(0,"end")
25682  AWGBFreqEntry.insert(0,100.0)
25683  # AWG Phase or delay select sub frame
25684  # AWG Phase sub frame
25685  awg2phase = Frame( frame2r )
25686  awg2phase.pack(side=TOP)
25687  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
25688  awgbph.pack(side=LEFT, anchor=W)
25689  AWGBPhaseEntry = Entry(awg2phase, width=5, cursor='double_arrow')
25690  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
25691  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
25692  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25693  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
25694  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
25695  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
25696  AWGBPhaseEntry.delete(0,"end")
25697  AWGBPhaseEntry.insert(0,0)
25698  phaseblab = Label(awg2phase, text="Deg")
25699  phaseblab.pack(side=LEFT, anchor=W)
25700  # AWG duty cycle frame
25701  awg2dc = Frame( frame2r )
25702  awg2dc.pack(side=TOP)
25703  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
25704  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
25705  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
25706  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25707  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
25708  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
25709  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
25710  AWGBDutyCycleEntry.delete(0,"end")
25711  AWGBDutyCycleEntry.insert(0,50)
25712  duty2lab = Label(awg2dc, text="%")
25713  duty2lab.pack(side=LEFT, anchor=W)
25714  #
25715  bcompa = Checkbutton(frame2r, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)
25716  bcompa.pack(side=TOP)
25717 
25718  awgsync = Checkbutton(frame2r, text="Sync AWG", variable=AWGSync, command=BAWGSync)
25719  awgsync.pack(side=TOP)
25720  if ShowBallonHelp > 0:
25721  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
25722  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
25723  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
25724  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
25725  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
25726  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
25727  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
25728  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
25729 
25730 # input probe wigets
25731 prlab = Button(frame2r, text="Adjust Gain/Offset", command=MakeResDivWindow)
25732 prlab.pack(side=TOP)
25733 # Input Probes sub frame
25734 ProbeA = Frame( frame2r )
25735 ProbeA.pack(side=TOP)
25736 gain1lab = Button(ProbeA, text="CA-V", width=4, style="Ctrace1.TButton", command=ReSetAGO)
25737 gain1lab.pack(side=LEFT,fill=X)
25738 CHAVGainEntry = Entry(ProbeA, width=5, cursor='double_arrow')
25739 CHAVGainEntry.bind('<Return>', onTextKey)
25740 CHAVGainEntry.bind('<MouseWheel>', onTextScroll)
25741 CHAVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25742 CHAVGainEntry.bind("<Button-5>", onTextScroll)
25743 CHAVGainEntry.bind('<Key>', onTextKey)
25744 CHAVGainEntry.pack(side=LEFT)
25745 CHAVGainEntry.delete(0,"end")
25746 CHAVGainEntry.insert(0,1.0)
25747 CHAVOffsetEntry = Entry(ProbeA, width=5, cursor='double_arrow')
25748 CHAVOffsetEntry.bind('<Return>', onTextKey)
25749 CHAVOffsetEntry.bind('<MouseWheel>', onTextScroll)
25750 CHAVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25751 CHAVOffsetEntry.bind("<Button-5>", onTextScroll)
25752 CHAVOffsetEntry.bind('<Key>', onTextKey)
25753 CHAVOffsetEntry.pack(side=LEFT)
25754 CHAVOffsetEntry.delete(0,"end")
25755 CHAVOffsetEntry.insert(0,0.0)
25756 #
25757 ProbeB = Frame( frame2r )
25758 ProbeB.pack(side=TOP)
25759 gain2lab = Button(ProbeB, text="CB-V", width=4, style="Ctrace2.TButton", command=ReSetBGO)
25760 gain2lab.pack(side=LEFT,fill=X)
25761 CHBVGainEntry = Entry(ProbeB, width=5, cursor='double_arrow')
25762 CHBVGainEntry.bind('<Return>', onTextKey)
25763 CHBVGainEntry.bind('<MouseWheel>', onTextScroll)
25764 CHBVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25765 CHBVGainEntry.bind("<Button-5>", onTextScroll)
25766 CHBVGainEntry.bind('<Key>', onTextKey)
25767 CHBVGainEntry.pack(side=LEFT)
25768 CHBVGainEntry.delete(0,"end")
25769 CHBVGainEntry.insert(0,1.0)
25770 CHBVOffsetEntry = Entry(ProbeB, width=5, cursor='double_arrow')
25771 CHBVOffsetEntry.bind('<Return>', onTextKey)
25772 CHBVOffsetEntry.bind('<MouseWheel>', onTextScroll)
25773 CHBVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25774 CHBVOffsetEntry.bind("<Button-5>", onTextScroll)
25775 CHBVOffsetEntry.bind('<Key>', onTextKey)
25776 CHBVOffsetEntry.pack(side=LEFT)
25777 CHBVOffsetEntry.delete(0,"end")
25778 CHBVOffsetEntry.insert(0,0.0)
25779 #
25780 ProbeAI = Frame( frame2r )
25781 ProbeAI.pack(side=TOP)
25782 gainailab = Button(ProbeAI, text="CA-I", width=4, style="Ctrace3.TButton", command=ReSetAIGO)
25783 gainailab.pack(side=LEFT,fill=X)
25784 CHAIGainEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
25785 CHAIGainEntry.bind('<Return>', onTextKey)
25786 CHAIGainEntry.bind('<MouseWheel>', onTextScroll)
25787 CHAIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25788 CHAIGainEntry.bind("<Button-5>", onTextScroll)
25789 CHAIGainEntry.bind('<Key>', onTextKey)
25790 CHAIGainEntry.pack(side=LEFT)
25791 CHAIGainEntry.delete(0,"end")
25792 CHAIGainEntry.insert(0,1.0)
25793 CHAIOffsetEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
25794 CHAIOffsetEntry.bind('<Return>', onTextKey)
25795 CHAIOffsetEntry.bind('<MouseWheel>', onTextScroll)
25796 CHAIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25797 CHAIOffsetEntry.bind("<Button-5>", onTextScroll)
25798 CHAIOffsetEntry.bind('<Key>', onTextKey)
25799 CHAIOffsetEntry.pack(side=LEFT)
25800 CHAIOffsetEntry.delete(0,"end")
25801 CHAIOffsetEntry.insert(0,0.0)
25802 #
25803 ProbeBI = Frame( frame2r )
25804 ProbeBI.pack(side=TOP)
25805 gainbilab = Button(ProbeBI, text="CB-I", width=4, style="Ctrace4.TButton", command=ReSetBIGO)
25806 gainbilab.pack(side=LEFT,fill=X)
25807 CHBIGainEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
25808 CHBIGainEntry.bind('<Return>', onTextKey)
25809 CHBIGainEntry.bind('<MouseWheel>', onTextScroll)
25810 CHBIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25811 CHBIGainEntry.bind("<Button-5>", onTextScroll)
25812 CHBIGainEntry.bind('<Key>', onTextKey)
25813 CHBIGainEntry.pack(side=LEFT)
25814 CHBIGainEntry.delete(0,"end")
25815 CHBIGainEntry.insert(0,1.0)
25816 CHBIOffsetEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
25817 CHBIOffsetEntry.bind('<Return>', onTextKey)
25818 CHBIOffsetEntry.bind('<MouseWheel>', onTextScroll)
25819 CHBIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25820 CHBIOffsetEntry.bind("<Button-5>", onTextScroll)
25821 CHBIOffsetEntry.bind('<Key>', onTextKey)
25822 CHBIOffsetEntry.pack(side=LEFT)
25823 CHBIOffsetEntry.delete(0,"end")
25824 CHBIOffsetEntry.insert(0,0.0)
25825 # Add a pair of user entry wigets
25826 if EnableUserEntries > 0:
25827  UserEnt = Frame( frame2r )
25828  UserEnt.pack(side=TOP)
25829  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
25830  userentlab.pack(side=LEFT,fill=X)
25831  User1Entry = Entry(UserEnt, width=5, cursor='double_arrow')
25832  User1Entry.bind('<Return>', onTextKey)
25833  User1Entry.bind('<MouseWheel>', onTextScroll)
25834  User1Entry.bind("<Button-4>", onTextScroll)# with Linux OS
25835  User1Entry.bind("<Button-5>", onTextScroll)
25836  User1Entry.bind('<Key>', onTextKey)
25837  User1Entry.pack(side=LEFT)
25838  User1Entry.delete(0,"end")
25839  User1Entry.insert(0,0.0)
25840  User2Entry = Entry(UserEnt, width=5, cursor='double_arrow')
25841  User2Entry.bind('<Return>', onTextKey)
25842  User2Entry.bind('<MouseWheel>', onTextScroll)
25843  User2Entry.bind("<Button-4>", onTextScroll)# with Linux OS
25844  User2Entry.bind("<Button-5>", onTextScroll)
25845  User2Entry.bind('<Key>', onTextKey)
25846  User2Entry.pack(side=LEFT)
25847  User2Entry.delete(0,"end")
25848  User2Entry.insert(0,0.0)
25849 # add ADI logo Don't mess with this bit map data!
25850 ADIlogo = """
25851 R0lGODlhdAAxAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
25852 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
25853 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
25854 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
25855 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
25856 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
25857 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
25858 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
25859 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
25860 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
25861 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
25862 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
25863 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
25864 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAB0ADEA
25865 AAj/AP8JHEiwoMGDCBMqXMiwocOHEBlSS5WKIUWJfqj9S+XnokGPEUOKdEito0WNCC9OpEbtz7+V
25866 HyuOnEnzI6yMEylWpNgx50aOGkt6LElUoB9VPFHyTAXrYipVNaOSTOWzEEuqA61SXTnxH06ZK7EK
25867 5Ap2J9WdKKWqRVjyJ1c/1ZbqvPnyrKqS215mzEiwo8yfer22XUs4Zse9V31mPFuxbdKxjAU65Si5
25868 8Vm+hTNXrvuWKFKdjs8WJEqR5V63bkP/1bx28E+rK28ihckRayHQnH/yVdUTMtB/1fywHj7TI0iR
25869 x4krd7g0bcjSy6NLn069uvXr2LNr3/6Sip/vU777//EOXjx5P+G/nw/vnCA18gXFOy+JWfL31V6/
25870 s001ZQqK8AdN1B8KJiVETX9TMIGggv0xmOCCEDbYX3sDoTdhXwi6199qFjJRUIMB3iEhgs7x56CC
25871 wrH134r+tcjiiy7G+B+FL7nIYYsp1ojCX9SwuFqLBh343xQc+bGiUjhyhCNbLTbR4oBTODlkk09S
25872 iQKNBz7Z139OotQjkQPxx2WO/3D5kZNUDDSRk8IJOUVabqoo45ww1tkijejt+N9fUM64kX9/GQne
25873 lQMBWdCRGs6Yyp4FFYllhIVM6aCkCFL65kGAHshEjhZa2NiGAlWzJzUK8pngaAmSKVAh/fHWX0Rf
25874 sv+oSnB01iprkIwOWKF//wzIEqBG8drrf4USS9CiYBYEy39/GCrQHzpZFWCVhOoFpZSVRkktheg1
25875 MRaoXhGLbEaM9tpEinmiNGSj4CaaipNTqKltuaPBOF+ftt6JKgpUnGUoFcIaGR6wX371X4rOjnXw
25876 R3tSYexLL+L37YgUmhjhgxSjijHGGln4rYMVoXdihr2eqiETdxhEooUUtuuevQEiayeL7eU5p3B5
25877 ZmXjsHRWlLBAWgA7ULME/rPsqxjuOC2X/tE4VrfUztuef6oCKXDSRBb8MoBc6gSalD1BDVW4E5rW
25878 osQQx+i0mgLbOd/CSWeJwtY7pvvhjLWmDWOOJc3/jHaWHDckd4TOsawxePEeuyGJ7O44opbWDukH
25879 LB8hOGFtAcI4dkNEx7g5d+6xtBBLa8s7ZbUk/XF66aBLFau+D/GntntbwdQo6bXnHmTu83FFO+6k
25880 wxm8QoAzyDrbI186UPIF/vk4in6UStA2DKaC4q4OKp98qsFmnPnsC21jM8zF3izZzB1RTRDRfrBa
25881 dMl1alSrcPgOmVeQVpYuYNRSOtf/RFDbSaaCJzop9cVJFOkPzs6mF3iVjEheo0qzmvAHpcCtXuA7
25882 iJjy5ZyE2Wwi9IpPub4ULzFlhIFP25P6DCKwzQlJVRML3EEstDFLOYdBH7qcyxQ3hUJIJkE7ORip
25883 /5CmptJcEENMQNv3bkW7mc3pcz8bl8xilKN1ka0i7HMfDMsHo42wqIdiWVqlSmSlbGHLVwTRleII
25884 tMFrccpPVnxXeGSnxH+csUk/tFJ96Aa7kuTLbWl82PnmKLn06OeHOxKTTExowoTgCD3i6UvbVqix
25885 wMlue5i80PKIuKoN0VEhCJLd2KzHnushxJSjuySFXnewP3IwkIkrH0WYpRCBkewfWnSTc1TRyvfF
25886 RwuqEtgqy3gt/hkTdXYUVl0cqEiFyE5ozlugL+GXpS32pwkdjNIqncjNWnXwYBZaEVSm+CIyQekv
25887 jYTffaDkpjqpzpOym6a8HmepKk2KcAS5J+OcV0JDAIXJioPMEZQaxJd6Kkqfe1RTNxfquWNRBFo6
25888 oV0qbvNQ6BQxjP/4TOGSpBSKUDQVEH2awHrTupKa9KQoTWl0AgIAOw==
25889 """
25890 logo = PhotoImage(data=ADIlogo)
25891 ADI1 = Label(frame2r, image=logo, anchor= "sw", compound="top") # , height=49, width=116
25892 ADI1.pack(side=TOP)
25893 
25894 # Bottom Buttons
25895 # Voltage channel A
25896 if ButtonOrder == 1:
25897  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
25898  CHAlab.pack(side=LEFT)
25899 CHAsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHvpdiv, command=BCHAlevel)
25900 #CHAsb = ttk.Spinbox(frame3, cursor='double_arrow', style="Div.TSpinbox", values=CHvpdiv, command=BCHAlevel)
25901 CHAsb.bind('<MouseWheel>', onSpinBoxScroll)
25902 CHAsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
25903 CHAsb.bind("<Button-5>", onSpinBoxScroll)
25904 CHAsb.pack(side=LEFT)
25905 CHAsb.delete(0,"end")
25906 CHAsb.insert(0,0.5)
25907 #
25908 if ButtonOrder == 0:
25909  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
25910  CHAlab.pack(side=LEFT)
25911 #
25912 if ButtonOrder == 1:
25913  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
25914  CHAofflab.pack(side=LEFT)
25915 CHAVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
25916 CHAVPosEntry.bind("<Return>", BOffsetA)
25917 CHAVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
25918 CHAVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25919 CHAVPosEntry.bind("<Button-5>", onTextScroll)
25920 CHAVPosEntry.bind('<Key>', onTextKey)
25921 CHAVPosEntry.pack(side=LEFT)
25922 CHAVPosEntry.delete(0,"end")
25923 CHAVPosEntry.insert(0,2.5)
25924 if ButtonOrder == 0:
25925  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
25926  CHAofflab.pack(side=LEFT)
25927 # Current channel A
25928 if ButtonOrder == 1:
25929  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
25930  CHAIlab.pack(side=LEFT)
25931 CHAIsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHipdiv, command=BCHAIlevel)
25932 CHAIsb.bind('<MouseWheel>', onSpinBoxScroll)
25933 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
25934 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
25935 CHAIsb.pack(side=LEFT)
25936 CHAIsb.delete(0,"end")
25937 CHAIsb.insert(0,50.0)
25938 if ButtonOrder == 0:
25939  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
25940  CHAIlab.pack(side=LEFT)
25941 #
25942 if ButtonOrder == 1:
25943  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
25944  CHAIofflab.pack(side=LEFT)
25945 CHAIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
25946 CHAIPosEntry.bind("<Return>", BIOffsetA)
25947 CHAIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
25948 CHAIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25949 CHAIPosEntry.bind("<Button-5>", onTextScroll)
25950 CHAIPosEntry.bind('<Key>', onTextKey)
25951 CHAIPosEntry.pack(side=LEFT)
25952 CHAIPosEntry.delete(0,"end")
25953 CHAIPosEntry.insert(0,0.0)
25954 if ButtonOrder == 0:
25955  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
25956  CHAIofflab.pack(side=LEFT)
25957 # Voltage channel B
25958 if ButtonOrder == 1:
25959  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
25960  CHBlab.pack(side=LEFT)
25961 CHBsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHvpdiv, command=BCHBlevel)
25962 CHBsb.bind('<MouseWheel>', onSpinBoxScroll)
25963 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
25964 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
25965 CHBsb.pack(side=LEFT)
25966 CHBsb.delete(0,"end")
25967 CHBsb.insert(0,0.5)
25968 #
25969 if ButtonOrder == 0:
25970  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
25971  CHBlab.pack(side=LEFT)
25972 #
25973 if ButtonOrder == 1:
25974  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
25975  CHBofflab.pack(side=LEFT)
25976 CHBVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
25977 CHBVPosEntry.bind("<Return>", BOffsetB)
25978 CHBVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
25979 CHBVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25980 CHBVPosEntry.bind("<Button-5>", onTextScroll)
25981 CHBVPosEntry.bind('<Key>', onTextKey)
25982 CHBVPosEntry.pack(side=LEFT)
25983 CHBVPosEntry.delete(0,"end")
25984 CHBVPosEntry.insert(0,2.5)
25985 if ButtonOrder == 0:
25986  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
25987  CHBofflab.pack(side=LEFT)
25988 # Current channel B
25989 if ButtonOrder == 1:
25990  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
25991  CHBIlab.pack(side=LEFT)
25992 CHBIsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHipdiv, command=BCHBIlevel)
25993 CHBIsb.bind('<MouseWheel>', onSpinBoxScroll)
25994 CHBIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
25995 CHBIsb.bind("<Button-5>", onSpinBoxScroll)
25996 CHBIsb.pack(side=LEFT)
25997 CHBIsb.delete(0,"end")
25998 CHBIsb.insert(0,50.0)
25999 if ButtonOrder == 0:
26000  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
26001  CHBIlab.pack(side=LEFT)
26002 #
26003 if ButtonOrder == 1:
26004  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
26005  CHBIofflab.pack(side=LEFT)
26006 CHBIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
26007 CHBIPosEntry.bind("<Return>", BIOffsetB)
26008 CHBIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
26009 CHBIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
26010 CHBIPosEntry.bind("<Button-5>", onTextScroll)
26011 CHBIPosEntry.bind('<Key>', onTextKey)
26012 CHBIPosEntry.pack(side=LEFT)
26013 CHBIPosEntry.delete(0,"end")
26014 CHBIPosEntry.insert(0,0.0)
26015 if ButtonOrder == 0:
26016  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
26017  CHBIofflab.pack(side=LEFT)
26018 #
26019 if ShowBallonHelp > 0:
26020  CHAlab_tip = CreateToolTip(CHAlab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
26021  CHBlab_tip = CreateToolTip(CHBlab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
26022  CHAIlab_tip = CreateToolTip(CHAIlab, 'Select CHA-I vertical range/position axis to be used for markers and drawn color')
26023  CHBIlab_tip = CreateToolTip(CHBIlab, 'Select CHB-I vertical range/position axis to be used for markers and drawn color')
26024  CHAofflab_tip = CreateToolTip(CHAofflab, 'Set CHA-V position to DC average of signal')
26025  CHBofflab_tip = CreateToolTip(CHBofflab, 'Set CHB-V position to DC average of signal')
26026  CHAIofflab_tip = CreateToolTip(CHAIofflab, 'Set CHA-I position to DC average of signal')
26027  CHBIofflab_tip = CreateToolTip(CHBIofflab, 'Set CHB-I position to DC average of signal')
26028  gain1lab_tip = CreateToolTip(gain1lab, 'Reset Gain to 1.0 and Offset to 0.0')
26029  gain2lab_tip = CreateToolTip(gain2lab, 'Reset Gain to 1.0 and Offset to 0.0')
26030  gainailab_tip = CreateToolTip(gainailab, 'Reset Gain to 1.0 and Offset to 0.0')
26031  gainbilab_tip = CreateToolTip(gainbilab, 'Reset Gain to 1.0 and Offset to 0.0')
26032  prlab_tip = CreateToolTip(prlab, 'Open Resistor Divider Gain Offset Calculator')
26033 #
26034 root.geometry('+300+0')
26035 root.protocol("WM_DELETE_WINDOW", Bcloseexit)
26036 #===== Initalize device ======
26037 if not numpy_found:
26038  root.update()
26039  showwarning("WARNING","Numpy not found!")
26040  root.destroy()
26041  exit()
26042 #
26043 BrdSel = IntVar(0)
26044 BoardStatus = IntVar(0)
26045 if pysmu_found:
26046  ConnectDevice()
26047  #session.hotplug_attach(ConnectDevice)
26048  #session.hotplug_detach(ConnectDevice)
26049  if EnableScopeOnly == 0:
26050  MakeAWGWindow() # build AWG window
26051  else:
26052  AWGScreenStatus.set(1)
26053  # root.update()
26054  BLoadConfig("alice-last-config.cfg") # load configuration from last session
26055  if LocalLanguage != "English":
26056  BLoadConfig(LocalLanguage) # load local language configuration
26057 # ================ Call main routine ===============================
26058  root.update() # Activate updated screens
26059 # Start sampling
26060  Analog_In()
26061 else:
26062  root.update()
26063  showwarning("WARNING","Pysmu not found!")
26064  root.destroy()
26065  exit()
26066 
alice-desktop-1.IApBtoggle
def IApBtoggle()
Definition: alice-desktop-1.3.pyw:16744
alice-desktop-1.Analog_Chop_Time
def Analog_Chop_Time()
Definition: alice-desktop-1.3-linux-test.pyw:4121
alice-desktop-1.DestroySpectrumScreen
def DestroySpectrumScreen()
Definition: alice-desktop-1.3-linux-test.pyw:19733
alice-desktop-1.ApplyMathString
def ApplyMathString()
Apply Math string from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2697
alice-desktop-1.DoNothing
def DoNothing(event)
Another Nop.
Definition: alice-desktop-1.3-linux-test.pyw:2731
alice-desktop-1.CheckMathString
def CheckMathString()
Check Math String for syntac errors.
Definition: alice-desktop-1.3-linux-test.pyw:2637
alice-desktop-1.DestroyPhAScreen
def DestroyPhAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:16112
alice-desktop-1.SetDualMuxMode
def SetDualMuxMode()
Definition: alice-desktop-1.3-linux-test.pyw:18940
alice-desktop-1.SetColorT2
def SetColorT2()
Definition: alice-desktop-1.3.pyw:2258
alice-desktop-1.UpdatePhAScreen
def UpdatePhAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:16139
alice-desktop-1.MakeMuxModeWindow
def MakeMuxModeWindow()
Definition: alice-desktop-1.3-linux-test.pyw:18744
alice-desktop-1.DlogerOpen_out
def DlogerOpen_out()
Definition: alice-desktop-1.3.pyw:24629
alice-desktop-1.DestroyBoardScreen
def DestroyBoardScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22081
alice-desktop-1.BLoadConfigTime
def BLoadConfigTime()
Load confirfuration from Scope window button.
Definition: alice-desktop-1.3-linux-test.pyw:1913
alice-desktop-1.BTriglevel
def BTriglevel(event)
evalute trigger level entry string to a numerical value and set new trigger level
Definition: alice-desktop-1.3-linux-test.pyw:2813
alice-desktop-1.DestroyCommandScreen
def DestroyCommandScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21837
alice-desktop-1.onSrateScroll
def onSrateScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22275
alice-desktop-1.BSweepSync
def BSweepSync()
Definition: alice-desktop-1.3-linux-test.pyw:19042
alice-desktop-1.IASourceSet
def IASourceSet()
Set up IA AWG sources.
Definition: alice-desktop-1.3-linux-test.pyw:3125
alice-desktop-1.Bsamples2
def Bsamples2()
Definition: alice-desktop-1.3-linux-test.pyw:13191
alice-desktop-1.onCanvasFive
def onCanvasFive(event)
Definition: alice-desktop-1.3-linux-test.pyw:9669
alice-desktop-1.UpdateTimeScreen
def UpdateTimeScreen()
Update time screen with trace and text.
Definition: alice-desktop-1.3-linux-test.pyw:6002
alice-desktop-1.BSaveConfigIA
def BSaveConfigIA()
Save current configuration from IA window.
Definition: alice-desktop-1.3-linux-test.pyw:1557
alice-desktop-1.onAWGFiltBScroll
def onAWGFiltBScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21656
alice-desktop-1.MakeFreqScreen
def MakeFreqScreen()
Make Spectrum Analyzer Screen.
Definition: alice-desktop-1.3-linux-test.pyw:17168
alice-desktop-1.BStartIA
def BStartIA()
Start Impedance Tool
Definition: alice-desktop-1.3-linux-test.pyw:3105
alice-desktop-1.SelectBoard
def SelectBoard()
temp = 0 print "read ADM1177 controler" print devx.ctrl_transfer( 0xa0, 0x17, 0, 0,...
Definition: alice-desktop-1.3-linux-test.pyw:22117
alice-desktop-1.RunScript
def RunScript()
Run a script file.
Definition: alice-desktop-1.3-linux-test.pyw:1920
alice-desktop-1.sel
def sel()
Definition: alice-desktop-1.3-linux-test.pyw:5648
alice-desktop-1.UpdateAWGA
def UpdateAWGA()
Definition: alice-desktop-1.3-linux-test.pyw:11359
alice-desktop-1.Analog_Roll_time
def Analog_Roll_time()
Definition: alice-desktop-1.3-linux-test.pyw:3986
alice-desktop-1.onMiniGenScroll
def onMiniGenScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:20773
alice-desktop-1.IncHoldOff
def IncHoldOff()
Definition: alice-desktop-1.3-linux-test.pyw:2867
alice-desktop-1.SetColorTR4
def SetColorTR4()
Definition: alice-desktop-1.3.pyw:2375
alice-desktop-1.UpdateIAScreen
def UpdateIAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:14738
alice-desktop-1.AWGBMakeMath
def AWGBMakeMath()
Definition: alice-desktop-1.3-linux-test.pyw:11882
alice-desktop-1.UpdateAwgContRet
def UpdateAwgContRet(temp)
Definition: alice-desktop-1.3-linux-test.pyw:12766
alice-desktop-1.ToggleAWGBPhaseDelay
def ToggleAWGBPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:11682
alice-desktop-1.AWGBMakeFullWaveSine
def AWGBMakeFullWaveSine()
Definition: alice-desktop-1.3.pyw:12696
alice-desktop-1.UpdateAWGWin
def UpdateAWGWin()
Definition: alice-desktop-1.3-linux-test.pyw:23134
alice-desktop-1.onRetSrate
def onRetSrate(event)
Definition: alice-desktop-1.3-linux-test.pyw:22281
alice-desktop-1.AWGBMakePWMSine
def AWGBMakePWMSine()
Definition: alice-desktop-1.3-linux-test.pyw:12020
alice-desktop-1.MakeXYTrace
def MakeXYTrace()
Make the XY plot traces.
Definition: alice-desktop-1.3-linux-test.pyw:7101
alice-desktop-1.onCanvasSeven
def onCanvasSeven(event)
Definition: alice-desktop-1.3-linux-test.pyw:9679
alice-desktop-1.ApplyMathYString
def ApplyMathYString()
Apply Y Math string from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2711
alice-desktop-1.DoImpedance
def DoImpedance()
Definition: alice-desktop-1.3-linux-test.pyw:14742
alice-desktop-1.BExecuteFromString
def BExecuteFromString()
Definition: alice-desktop-1.3-linux-test.pyw:21847
alice-desktop-1.STOREcsvfile
def STOREcsvfile()
Definition: alice-desktop-1.3-linux-test.pyw:17084
alice-desktop-1.AWGBMakeRamp
def AWGBMakeRamp()
Definition: alice-desktop-1.3-linux-test.pyw:12310
alice-desktop-1.AWGBReadFile
def AWGBReadFile()
Definition: alice-desktop-1.3-linux-test.pyw:11775
alice-desktop-1.DestroyETSScreen
def DestroyETSScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22688
alice-desktop-1.onCanvasShowTcur
def onCanvasShowTcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:9721
alice-desktop-1.SetIBPoss
def SetIBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2975
alice-desktop-1.Sine_Phase
def Sine_Phase()
Definition: alice-desktop-1.3-linux-test.pyw:4937
alice-desktop-1.UpdateIAAll
def UpdateIAAll()
Definition: alice-desktop-1.3-linux-test.pyw:14724
alice-desktop-1.ETSscroll
def ETSscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22706
alice-desktop-1.AWGAMakeUUNoise
def AWGAMakeUUNoise()
Definition: alice-desktop-1.3-linux-test.pyw:11246
alice-desktop-1.SetColorTR2
def SetColorTR2()
Definition: alice-desktop-1.3.pyw:2353
alice-desktop-1.BOffsetB
def BOffsetB(event)
Definition: alice-desktop-1.3-linux-test.pyw:3300
alice-desktop-1.MakeIATrace
def MakeIATrace()
Definition: alice-desktop-1.3-linux-test.pyw:14786
alice-desktop-1.BDBdiv1
def BDBdiv1()
Definition: alice-desktop-1.3-linux-test.pyw:13212
alice-desktop-1.ColorSelector
def ColorSelector()
Color Selector / Editor.
Definition: alice-desktop-1.3.pyw:2117
alice-desktop-1.BStopSA
def BStopSA()
Definition: alice-desktop-1.3-linux-test.pyw:13107
alice-desktop-1.onCanvasAverage
def onCanvasAverage(event)
Definition: alice-desktop-1.3-linux-test.pyw:9713
alice-desktop-1.RDSetAGO
def RDSetAGO()
Definition: alice-desktop-1.3.pyw:23574
alice-desktop-1.Analog_Fast_time
def Analog_Fast_time()
Definition: alice-desktop-1.3-linux-test.pyw:4192
alice-desktop-1.BNormalmode
def BNormalmode()
Definition: alice-desktop-1.3-linux-test.pyw:12847
alice-desktop-1.BIOffsetB
def BIOffsetB(event)
Definition: alice-desktop-1.3-linux-test.pyw:3312
alice-desktop-1.BLoadDFiltB
def BLoadDFiltB()
Definition: alice-desktop-1.3-linux-test.pyw:21589
alice-desktop-1.BFileFFTwindow
def BFileFFTwindow()
Definition: alice-desktop-1.3-linux-test.pyw:17749
alice-desktop-1.NewEnterMathControls
def NewEnterMathControls()
Make New Math waveform controls menu window.
Definition: alice-desktop-1.3-linux-test.pyw:2475
alice-desktop-1.DestroyXYScreen
def DestroyXYScreen()
Definition: alice-desktop-1.3-linux-test.pyw:20032
alice-desktop-1.UpdateNiCAll
def UpdateNiCAll()
Definition: alice-desktop-1.3-linux-test.pyw:15866
alice-desktop-1.UpdateNqPAll
def UpdateNqPAll()
Definition: alice-desktop-1.3-linux-test.pyw:15847
alice-desktop-1.BSTOREtraceBP
def BSTOREtraceBP()
Definition: alice-desktop-1.3-linux-test.pyw:12918
alice-desktop-1.BTriggerEdge
def BTriggerEdge()
Function no longer used.
Definition: alice-desktop-1.3-linux-test.pyw:2754
alice-desktop-1.SetXYScaleA
def SetXYScaleA()
Definition: alice-desktop-1.3-linux-test.pyw:9090
alice-desktop-1.onMulXScroll
def onMulXScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22716
alice-desktop-1.BCHAlevel
def BCHAlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3232
alice-desktop-1.AWGAMakeFMSine
def AWGAMakeFMSine()
Definition: alice-desktop-1.3-linux-test.pyw:10579
alice-desktop-1.VBtoggle
def VBtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15902
alice-desktop-1.BSaveScreenBP
def BSaveScreenBP()
Save Bode canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2088
alice-desktop-1.AddAWGANoise
def AddAWGANoise()
Definition: alice-desktop-1.3-linux-test.pyw:11492
alice-desktop-1.MakeIAWindow
def MakeIAWindow()
Definition: alice-desktop-1.3-linux-test.pyw:15330
alice-desktop-1.onCanvasXYLeftClick
def onCanvasXYLeftClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:9768
alice-desktop-1.UpdateFreqAll
def UpdateFreqAll()
Definition: alice-desktop-1.3-linux-test.pyw:13447
alice-desktop-1.onCanvasShowBdBcur
def onCanvasShowBdBcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18195
alice-desktop-1.RExecuteFromString
def RExecuteFromString(temp)
Definition: alice-desktop-1.3-linux-test.pyw:21843
alice-desktop-1.AWGALoadCSV
def AWGALoadCSV()
Definition: alice-desktop-1.3-linux-test.pyw:10354
alice-desktop-1.onCanvasFreqLeftClick
def onCanvasFreqLeftClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:17803
alice-desktop-1.SetXYVAPoss
def SetXYVAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2981
alice-desktop-1.AddAWGBNoise
def AddAWGBNoise()
Definition: alice-desktop-1.3-linux-test.pyw:12729
alice-desktop-1.BSaveConfigBP
def BSaveConfigBP()
Save current configuration from Bode window.
Definition: alice-desktop-1.3-linux-test.pyw:1569
alice-desktop-1.DestroyNqPScreen
def DestroyNqPScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15578
alice-desktop-1.UpdatePotSlider
def UpdatePotSlider()
Definition: alice-desktop-1.3-linux-test.pyw:20995
alice-desktop-1.onCanvasBodeLeftClick
def onCanvasBodeLeftClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:18043
alice-desktop-1.BAWGAModeLabel
def BAWGAModeLabel()
Definition: alice-desktop-1.3-linux-test.pyw:11336
alice-desktop-1.BrownNoise
def BrownNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10031
alice-desktop-1.MakePhAScreen
def MakePhAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:16345
alice-desktop-1.BLoadDFiltAClip
def BLoadDFiltAClip()
Definition: alice-desktop-1.3-linux-test.pyw:2203
alice-desktop-1.BSnapShotXY
def BSnapShotXY()
Take snap shot of displayed XY Traces.
Definition: alice-desktop-1.3-linux-test.pyw:2318
alice-desktop-1.AWGBMakeSSQ
def AWGBMakeSSQ()
Definition: alice-desktop-1.3-linux-test.pyw:12116
alice-desktop-1.DestroyIAScreen
def DestroyIAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15526
alice-desktop-1.BReadFromClipboard
def BReadFromClipboard()
Definition: alice-desktop-1.3-linux-test.pyw:2193
alice-desktop-1.BAWG2X
def BAWG2X()
Definition: alice-desktop-1.3-linux-test.pyw:18715
alice-desktop-1.onCanvasMouse_xy
def onCanvasMouse_xy(event)
Definition: alice-desktop-1.3-linux-test.pyw:23331
alice-desktop-1.MakeFreqTrace
def MakeFreqTrace()
Definition: alice-desktop-1.3-linux-test.pyw:13800
alice-desktop-1.onAWGBkey
def onAWGBkey(event)
Definition: alice-desktop-1.3-linux-test.pyw:18264
alice-desktop-1.DlogerClose_out
def DlogerClose_out()
Definition: alice-desktop-1.3.pyw:24616
alice-desktop-1.AWGAMakeSSQ
def AWGAMakeSSQ()
Definition: alice-desktop-1.3-linux-test.pyw:10862
alice-desktop-1.onCanvasShowPcur
def onCanvasShowPcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18004
alice-desktop-1.AWGAReadWAV
def AWGAReadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:10428
alice-desktop-1.onCanvasThree
def onCanvasThree(event)
Definition: alice-desktop-1.3-linux-test.pyw:9653
alice-desktop-1.DestroyOOTwindow
def DestroyOOTwindow()
Definition: alice-desktop-1.3-linux-test.pyw:23500
alice-desktop-1.UpdateNqPScreen
def UpdateNqPScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15861
alice-desktop-1.AWGAMakePulse
def AWGAMakePulse()
Definition: alice-desktop-1.3-linux-test.pyw:10988
alice-desktop-1.Dloger_on_off
def Dloger_on_off()
Definition: alice-desktop-1.3.pyw:24605
alice-desktop-1.MakeAD5626Window
def MakeAD5626Window()
Make Controls for AD5626 serial DAC.
Definition: alice-desktop-1.3-linux-test.pyw:21143
alice-desktop-1.onCanvasSAZero
def onCanvasSAZero(event)
Definition: alice-desktop-1.3-linux-test.pyw:17971
alice-desktop-1.AWGAMakeSinc
def AWGAMakeSinc()
Definition: alice-desktop-1.3-linux-test.pyw:10804
alice-desktop-1.DestroyOhmScreen
def DestroyOhmScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22581
alice-desktop-1.SetColorTR5
def SetColorTR5()
Definition: alice-desktop-1.3.pyw:2386
alice-desktop-1.BDSweepFromFile
def BDSweepFromFile()
Definition: alice-desktop-1.3-linux-test.pyw:19052
alice-desktop-1.onCanvasXYScrollClick
def onCanvasXYScrollClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:9746
alice-desktop-1.AWGBMakePulse
def AWGBMakePulse()
Definition: alice-desktop-1.3-linux-test.pyw:12240
alice-desktop-1.SetTriggerPoss
def SetTriggerPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2849
alice-desktop-1.SetColorT5
def SetColorT5()
Definition: alice-desktop-1.3.pyw:2303
alice-desktop-1.ApplyMathXString
def ApplyMathXString()
Apply X Math string from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2704
alice-desktop-1.SetScaleMuxB
def SetScaleMuxB()
Definition: alice-desktop-1.3-linux-test.pyw:2921
alice-desktop-1.AWGANumCycles
def AWGANumCycles()
Definition: alice-desktop-1.3-linux-test.pyw:10414
alice-desktop-1.onCanvasSAPeak
def onCanvasSAPeak(event)
Definition: alice-desktop-1.3-linux-test.pyw:17981
alice-desktop-1.onCanvasRightArrow
def onCanvasRightArrow(event)
Move Time curcors right 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9284
alice-desktop-1.onRetAWGFiltB
def onRetAWGFiltB(event)
Definition: alice-desktop-1.3-linux-test.pyw:21653
alice-desktop-1.ToggleAWGAPhaseDelay
def ToggleAWGAPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:10256
alice-desktop-1.onCanvasShowBPcur
def onCanvasShowBPcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18188
alice-desktop-1.CreateToolTip.tw
tw
Definition: alice-desktop-1.3-linux-test.pyw:893
alice-desktop-1.BAWGFiltBMath
def BAWGFiltBMath()
Definition: alice-desktop-1.3-linux-test.pyw:21744
alice-desktop-1.onCanvasSAThree
def onCanvasSAThree(event)
Definition: alice-desktop-1.3-linux-test.pyw:17928
alice-desktop-1.MakeNiCScreen
def MakeNiCScreen()
Make the Nichols Plot screen.
Definition: alice-desktop-1.3-linux-test.pyw:15722
alice-desktop-1.DestroyDigPotScreen
def DestroyDigPotScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21063
alice-desktop-1.ReInterploateTrigger
def ReInterploateTrigger(TrgBuff)
Interpolate time between samples around trigger event.
Definition: alice-desktop-1.3-linux-test.pyw:5512
alice-desktop-1.onCanvasZero
def onCanvasZero(event)
Definition: alice-desktop-1.3-linux-test.pyw:9694
alice-desktop-1.BShowCurvesNoneSA
def BShowCurvesNoneSA()
Definition: alice-desktop-1.3-linux-test.pyw:12840
alice-desktop-1.BAWGAPhase
def BAWGAPhase(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10278
alice-desktop-1.BAWGBPhaseDelay
def BAWGBPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:11694
alice-desktop-1.UpdateTimeTrace
def UpdateTimeTrace()
Update time trace and screen.
Definition: alice-desktop-1.3-linux-test.pyw:5997
alice-desktop-1.SetColorT7
def SetColorT7()
Definition: alice-desktop-1.3.pyw:2328
alice-desktop-1.AWGALoadWAV
def AWGALoadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:10437
alice-desktop-1.BSaveData
def BSaveData()
Save scope all time array data to file.
Definition: alice-desktop-1.3-linux-test.pyw:2105
alice-desktop-1.XYCheckBox
def XYCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3331
alice-desktop-1.Bcloseexit
def Bcloseexit()
Fubntion to close and exit ALICE.
Definition: alice-desktop-1.3-linux-test.pyw:3005
alice-desktop-1.DestroyMathScreen
def DestroyMathScreen()
Destroy New Math waveform controls menu window.
Definition: alice-desktop-1.3-linux-test.pyw:2630
alice-desktop-1.BIOffsetA
def BIOffsetA(event)
Definition: alice-desktop-1.3-linux-test.pyw:3288
alice-desktop-1.SetADC_Mux
def SetADC_Mux()
Definition: alice-desktop-1.3-linux-test.pyw:22362
alice-desktop-1.BLoadConfig
def BLoadConfig(filename)
Load configuration from a file
Definition: alice-desktop-1.3-linux-test.pyw:1580
alice-desktop-1.onCanvasBdZero
def onCanvasBdZero(event)
Definition: alice-desktop-1.3-linux-test.pyw:18181
alice-desktop-1.BSaveConfigTime
def BSaveConfigTime()
Save current configuration from Scope window.
Definition: alice-desktop-1.3-linux-test.pyw:1575
alice-desktop-1.UpdatePhATrace
def UpdatePhATrace()
Definition: alice-desktop-1.3-linux-test.pyw:16135
alice-desktop-1.BLoadAWGFiltA
def BLoadAWGFiltA()
Definition: alice-desktop-1.3-linux-test.pyw:21679
alice-desktop-1.BuildBoxCarA
def BuildBoxCarA()
Definition: alice-desktop-1.3-linux-test.pyw:21502
alice-desktop-1.SetColorTR1
def SetColorTR1()
Definition: alice-desktop-1.3.pyw:2342
alice-desktop-1.onCanvasTwo
def onCanvasTwo(event)
Definition: alice-desktop-1.3-linux-test.pyw:9645
alice-desktop-1.BHelp
def BHelp()
Open User Guide in Browser open a URL, in this case, the ALICE desk-top-users-guide.
Definition: alice-desktop-1.3-linux-test.pyw:2262
alice-desktop-1.SetVBPoss
def SetVBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2963
font
alice-desktop-1.AWGBMakeUUNoise
def AWGBMakeUUNoise()
Definition: alice-desktop-1.3-linux-test.pyw:12494
alice-desktop-1.ReMakeAWGwaves
def ReMakeAWGwaves()
Re Make the current selected AWG waveform buffers.
Definition: alice-desktop-1.3-linux-test.pyw:1768
alice-desktop-1.AWGBMakeImpulse
def AWGBMakeImpulse()
Definition: alice-desktop-1.3-linux-test.pyw:12439
alice-desktop-1.SetETSComp
def SetETSComp()
Definition: alice-desktop-1.3-linux-test.pyw:23100
alice-desktop-1.IAtoggle
def IAtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15910
alice-desktop-1.MakeETSWindow
def MakeETSWindow()
Definition: alice-desktop-1.3-linux-test.pyw:22589
alice-desktop-1.SetScaleB
def SetScaleB()
Definition: alice-desktop-1.3-linux-test.pyw:9066
alice-desktop-1.AWGBReadWAV
def AWGBReadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:11841
alice-desktop-1.INITIALIZEstart
def INITIALIZEstart()
Definition: alice-desktop-1.3-linux-test.pyw:17636
alice-desktop-1.BAWGBDutyCycle
def BAWGBDutyCycle(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11722
alice-desktop-1.BAWGAOffset
def BAWGAOffset(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10183
alice-desktop-1.Digital_RC_Low_Pass
def Digital_RC_Low_Pass(InBuff, TC1, Gain)
Digital filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3-linux-test.pyw:4980
alice-desktop-1.time_points_from_freq
def time_points_from_freq(freq, fs=1, density=False)
Definition: alice-desktop-1.3-linux-test.pyw:9949
alice-desktop-1.Digital_RC_High_Pass
def Digital_RC_High_Pass(InBuff, TC1, Gain)
Digital RC filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3-linux-test.pyw:4959
alice-desktop-1.UpdateMeasureScreen
def UpdateMeasureScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21926
alice-desktop-1.onCanvasClickRight
def onCanvasClickRight(event)
Definition: alice-desktop-1.3-linux-test.pyw:9104
alice-desktop-1.onCanvasSANine
def onCanvasSANine(event)
Definition: alice-desktop-1.3-linux-test.pyw:17967
alice-desktop-1.BLoadDFiltBClip
def BLoadDFiltBClip()
Definition: alice-desktop-1.3-linux-test.pyw:2209
alice-desktop-1.onCanvasBdSeven
def onCanvasBdSeven(event)
Definition: alice-desktop-1.3-linux-test.pyw:18166
alice-desktop-1.sel1
def sel1(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5871
alice-desktop-1.BAWGBShape
def BAWGBShape()
Definition: alice-desktop-1.3-linux-test.pyw:11741
alice-desktop-1.BDFiltBMath
def BDFiltBMath()
Definition: alice-desktop-1.3-linux-test.pyw:21612
alice-desktop-1.IBtoggle
def IBtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15918
alice-desktop-1.CreateToolTip.widget
widget
Definition: alice-desktop-1.3-linux-test.pyw:887
alice-desktop-1.BStartOhm
def BStartOhm()
Definition: alice-desktop-1.3-linux-test.pyw:3087
alice-desktop-1.MakeSampleRateMenu
def MakeSampleRateMenu()
Definition: alice-desktop-1.3-linux-test.pyw:22207
alice-desktop-1.BReadData
def BReadData()
Read scope all time array data from saved file.
Definition: alice-desktop-1.3-linux-test.pyw:2228
alice-desktop-1.AWGBMakeHalfWaveSine
def AWGBMakeHalfWaveSine()
Definition: alice-desktop-1.3.pyw:12767
alice-desktop-1.MakeGenericSerialWindow
def MakeGenericSerialWindow()
Definition: alice-desktop-1.3-linux-test.pyw:21223
alice-desktop-1.onDigFiltAScroll
def onDigFiltAScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21498
alice-desktop-1.SetScaleMuxD
def SetScaleMuxD()
Definition: alice-desktop-1.3-linux-test.pyw:2945
alice-desktop-1.UpdateAwgCont
def UpdateAwgCont()
Definition: alice-desktop-1.3-linux-test.pyw:12756
alice-desktop-1.onCanvasSASnap
def onCanvasSASnap(event)
Definition: alice-desktop-1.3-linux-test.pyw:17975
alice-desktop-1.BShowCurvesAll
def BShowCurvesAll()
Set to display all time waveforms.
Definition: alice-desktop-1.3-linux-test.pyw:2734
alice-desktop-1.onRetDigFiltB
def onRetDigFiltB(event)
Definition: alice-desktop-1.3-linux-test.pyw:21520
alice-desktop-1.DigPotShiftOut
def DigPotShiftOut(DValue)
Definition: alice-desktop-1.3-linux-test.pyw:20919
alice-desktop-1.MakeNqPScreen
def MakeNqPScreen()
Draw the Nyquist plot screen.
Definition: alice-desktop-1.3-linux-test.pyw:15595
alice-desktop-1.PhACheckBox
def PhACheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3378
alice-desktop-1.SetXYVBPoss
def SetXYVBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2987
alice-desktop-1.SchroederPhase
def SchroederPhase(Length, NrTones, Ampl)
Definition: alice-desktop-1.3-linux-test.pyw:10063
alice-desktop-1.Blevel3BP
def Blevel3BP()
Definition: alice-desktop-1.3-linux-test.pyw:13377
alice-desktop-1.BSnapShot
def BSnapShot()
Take snap shot of displayed time waveforms.
Definition: alice-desktop-1.3-linux-test.pyw:2287
alice-desktop-1.AWGAMakeRamp
def AWGAMakeRamp()
Definition: alice-desktop-1.3-linux-test.pyw:11059
alice-desktop-1.DestroyDacScreen
def DestroyDacScreen()
Destroy the DAC Screen.
Definition: alice-desktop-1.3-linux-test.pyw:5832
alice-desktop-1.fit_exp
def fit_exp(xs, ys)
Definition: alice-desktop-1.3-linux-test.pyw:21792
alice-desktop-1.onCanvasBdOne
def onCanvasBdOne(event)
Definition: alice-desktop-1.3-linux-test.pyw:18124
alice-desktop-1.UnWrap
def UnWrap(InArray, WrFactor)
Definition: alice-desktop-1.3-linux-test.pyw:10090
alice-desktop-1.CreateToolTip.waittime
waittime
Definition: alice-desktop-1.3-linux-test.pyw:885
alice-desktop-1.SinePower
def SinePower(Length, Power, Phase, Ampl)
Definition: alice-desktop-1.3.pyw:10578
alice-desktop-1.BSaveIASweep
def BSaveIASweep()
Definition: alice-desktop-1.3-linux-test.pyw:15534
alice-desktop-1.BSendDA1
def BSendDA1()
Definition: alice-desktop-1.3-linux-test.pyw:20818
alice-desktop-1.SetColorTR7
def SetColorTR7()
Definition: alice-desktop-1.3.pyw:2408
alice-desktop-1.SyncImage
def SyncImage()
Definition: alice-desktop-1.3-linux-test.pyw:18999
alice-desktop-1.AWGAMakeMath
def AWGAMakeMath()
Definition: alice-desktop-1.3-linux-test.pyw:10481
alice-desktop-1.BTrigger50p
def BTrigger50p()
Set Trigger level to 50% (mid) point of current waveform.
Definition: alice-desktop-1.3-linux-test.pyw:2760
alice-desktop-1.onCanvasBdEight
def onCanvasBdEight(event)
Definition: alice-desktop-1.3-linux-test.pyw:18173
alice-desktop-1.onCanvasSATwo
def onCanvasSATwo(event)
Definition: alice-desktop-1.3-linux-test.pyw:17921
alice-desktop-1.BTriggerMode
def BTriggerMode()
place holder for future hardware triggering if implemented
Definition: alice-desktop-1.3-linux-test.pyw:2801
alice-desktop-1.BShowCurvesNone
def BShowCurvesNone()
Turn off display of all time waveforms.
Definition: alice-desktop-1.3-linux-test.pyw:2744
alice-desktop-1.ResetAllColors
def ResetAllColors()
Definition: alice-desktop-1.3.pyw:2199
alice-desktop-1.UpdateNiCScreen
def UpdateNiCScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15880
alice-desktop-1.MakeSpectrumWindow
def MakeSpectrumWindow()
Definition: alice-desktop-1.3-linux-test.pyw:19421
alice-desktop-1.BAWGBModeLabel
def BAWGBModeLabel()
Definition: alice-desktop-1.3-linux-test.pyw:12579
alice-desktop-1.MakeDigScreen
def MakeDigScreen()
Make the Digital I/O screen.
Definition: alice-desktop-1.3-linux-test.pyw:5752
alice-desktop-1.SetBCompA
def SetBCompA()
Definition: alice-desktop-1.3-linux-test.pyw:11519
alice-desktop-1.onCanvasBdSnap
def onCanvasBdSnap(event)
Definition: alice-desktop-1.3-linux-test.pyw:18185
alice-desktop-1.onCanvasLeftArrow
def onCanvasLeftArrow(event)
Move Time curcors left 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9242
alice-desktop-1.BSaveConfigSA
def BSaveConfigSA()
Save current configuration from SA window.
Definition: alice-desktop-1.3-linux-test.pyw:1563
alice-desktop-1.UpdateAWGB
def UpdateAWGB()
Definition: alice-desktop-1.3-linux-test.pyw:12602
alice-desktop-1.SetMuxCPoss
def SetMuxCPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2897
alice-desktop-1.SelfCalibration
def SelfCalibration()
Definition: alice-desktop-1.3-linux-test.pyw:20043
alice-desktop-1.MakeNicPlot
def MakeNicPlot()
Definition: alice-desktop-1.3-linux-test.pyw:15679
alice-desktop-1.onCanvasBdTwo
def onCanvasBdTwo(event)
Definition: alice-desktop-1.3-linux-test.pyw:18131
alice-desktop-1.AWGAWriteFile
def AWGAWriteFile()
Definition: alice-desktop-1.3-linux-test.pyw:10475
alice-desktop-1.onRetAWGFiltA
def onRetAWGFiltA(event)
Definition: alice-desktop-1.3-linux-test.pyw:21627
alice-desktop-1.onCanvasShowFcur
def onCanvasShowFcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:17990
alice-desktop-1.BuildBoxCarB
def BuildBoxCarB()
Definition: alice-desktop-1.3-linux-test.pyw:21527
alice-desktop-1.onCanvasBdFive
def onCanvasBdFive(event)
Definition: alice-desktop-1.3-linux-test.pyw:18152
alice-desktop-1.onCanvasFour
def onCanvasFour(event)
Definition: alice-desktop-1.3-linux-test.pyw:9661
alice-desktop-1.AWGBMakeTrapazoid
def AWGBMakeTrapazoid()
Definition: alice-desktop-1.3-linux-test.pyw:12175
alice-desktop-1.CreateToolTip.id
id
Definition: alice-desktop-1.3-linux-test.pyw:892
alice-desktop-1.MakeMeasureScreen
def MakeMeasureScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21959
alice-desktop-1.BResetFreqAvg
def BResetFreqAvg()
Definition: alice-desktop-1.3-linux-test.pyw:12877
alice-desktop-1.BCHBlevel
def BCHBlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3254
alice-desktop-1.onSpinBoxScroll
def onSpinBoxScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18327
alice-desktop-1.onCanvasSix
def onCanvasSix(event)
Definition: alice-desktop-1.3-linux-test.pyw:9674
alice-desktop-1.Blevel4BP
def Blevel4BP()
Definition: alice-desktop-1.3-linux-test.pyw:13386
alice-desktop-1.BAWGBPhase
def BAWGBPhase(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11704
alice-desktop-1.SetColorTR3
def SetColorTR3()
Definition: alice-desktop-1.3.pyw:2364
alice-desktop-1.BDFiltAMath
def BDFiltAMath()
Definition: alice-desktop-1.3-linux-test.pyw:21574
alice-desktop-1.DestroySampleRate
def DestroySampleRate()
Definition: alice-desktop-1.3-linux-test.pyw:22268
alice-desktop-1.MakePhATrace
def MakePhATrace()
Definition: alice-desktop-1.3-linux-test.pyw:16144
alice-desktop-1.onCanvasShowPdBcur
def onCanvasShowPdBcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18202
alice-desktop-1.BStartSA
def BStartSA()
Definition: alice-desktop-1.3-linux-test.pyw:13064
alice-desktop-1.BSTOREtraceSA
def BSTOREtraceSA()
Definition: alice-desktop-1.3-linux-test.pyw:12883
alice-desktop-1.BAWGAFreq
def BAWGAFreq(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10221
alice-desktop-1.onCanvasBdNine
def onCanvasBdNine(event)
Definition: alice-desktop-1.3-linux-test.pyw:18177
alice-desktop-1.DestroyMeasureScreen
def DestroyMeasureScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22026
alice-desktop-1.Blevel3
def Blevel3()
Definition: alice-desktop-1.3-linux-test.pyw:13152
alice-desktop-1.Blevel2BP
def Blevel2BP()
Definition: alice-desktop-1.3-linux-test.pyw:13368
alice-desktop-1.BLoadConfigSA
def BLoadConfigSA()
Load confirfuration from SA window button.
Definition: alice-desktop-1.3-linux-test.pyw:1901
alice-desktop-1.onCanvasSAFive
def onCanvasSAFive(event)
Definition: alice-desktop-1.3-linux-test.pyw:17942
alice-desktop-1.BSaveConfig
def BSaveConfig(filename)
Save current configureation to file.
Definition: alice-desktop-1.3-linux-test.pyw:940
alice-desktop-1.MakeBodeTrace
def MakeBodeTrace()
Definition: alice-desktop-1.3-linux-test.pyw:14153
alice-desktop-1.DestroyMinigenScreen
def DestroyMinigenScreen()
Destroy DDS board sacrren.
Definition: alice-desktop-1.3-linux-test.pyw:20767
alice-desktop-1.onCanvasBdSix
def onCanvasBdSix(event)
Definition: alice-desktop-1.3-linux-test.pyw:18159
alice-desktop-1.MakeOhmWindow
def MakeOhmWindow()
if askyesno("Flash Failed", "Failed to update firmware.\n Try again?"): try: session....
Definition: alice-desktop-1.3-linux-test.pyw:22511
alice-desktop-1.onAWGAkey
def onAWGAkey(event)
Definition: alice-desktop-1.3-linux-test.pyw:18258
alice-desktop-1.MakeXYScreen
def MakeXYScreen()
Update the XY screen traces and text.
Definition: alice-desktop-1.3-linux-test.pyw:8272
alice-desktop-1.onCanvasNine
def onCanvasNine(event)
Definition: alice-desktop-1.3-linux-test.pyw:9689
alice-desktop-1.onDigFiltBScroll
def onDigFiltBScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21523
alice-desktop-1.Analog_In
def Analog_In()
Main Loop.
Definition: alice-desktop-1.3-linux-test.pyw:3415
alice-desktop-1.PhACaresize
def PhACaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:16121
alice-desktop-1.BStepSync
def BStepSync()
Definition: alice-desktop-1.3-linux-test.pyw:19032
alice-desktop-1.BSaveCal
def BSaveCal()
Save gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3-linux-test.pyw:2338
alice-desktop-1.AWGBMakeUpDownRamp
def AWGBMakeUpDownRamp()
Definition: alice-desktop-1.3-linux-test.pyw:12372
alice-desktop-1.UpdateBodeTrace
def UpdateBodeTrace()
Definition: alice-desktop-1.3-linux-test.pyw:13438
alice-desktop-1.onCanvasClickLeft
def onCanvasClickLeft(event)
Definition: alice-desktop-1.3-linux-test.pyw:9367
alice-desktop-1.Analog_Time_In
def Analog_Time_In()
Scope time main loop Read the analog data and store the data into the arrays.
Definition: alice-desktop-1.3-linux-test.pyw:3700
alice-desktop-1.UpdateFirmware
def UpdateFirmware()
Definition: alice-desktop-1.3-linux-test.pyw:22470
alice-desktop-1.MakeMinigenWindow
def MakeMinigenWindow()
Make AD983x based DDS generator screen.
Definition: alice-desktop-1.3-linux-test.pyw:20687
alice-desktop-1.ReSetAGO
def ReSetAGO()
Definition: alice-desktop-1.3-linux-test.pyw:23345
alice-desktop-1.UpdateNqPTrace
def UpdateNqPTrace()
Definition: alice-desktop-1.3-linux-test.pyw:15856
alice-desktop-1.SPIShiftOut
def SPIShiftOut(DValue)
========== MiniGen routines ========== SPI shift output routine
Definition: alice-desktop-1.3-linux-test.pyw:20603
alice-desktop-1.IACapReset
def IACapReset()
Definition: alice-desktop-1.3-linux-test.pyw:15547
alice-desktop-1.MakeHistogram
def MakeHistogram()
Make histogram of time signals.
Definition: alice-desktop-1.3-linux-test.pyw:5312
alice-desktop-1.MakeDacScreen
def MakeDacScreen()
Make the DAC interface screen
Definition: alice-desktop-1.3-linux-test.pyw:5970
alice-desktop-1.DigPotSend
def DigPotSend(Temp)
Definition: alice-desktop-1.3-linux-test.pyw:20954
alice-desktop-1.PlotPhAFromFile
def PlotPhAFromFile()
Definition: alice-desktop-1.3-linux-test.pyw:17028
alice-desktop-1.FreqCheckBox
def FreqCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3338
alice-desktop-1.CAresize
def CAresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:21916
alice-desktop-1.onCanvasXYRightClick
def onCanvasXYRightClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:9737
alice-desktop-1.CheckMathXString
def CheckMathXString()
Check X Math String for syntac errors.
Definition: alice-desktop-1.3-linux-test.pyw:2657
alice-desktop-1.DA1ShiftOut
def DA1ShiftOut(D1Value, D2Value)
if ETSStatus.get() > 0 and ETSDisp.get() > 0: MGLoad()
Definition: alice-desktop-1.3-linux-test.pyw:20780
alice-desktop-1.SetColorTrig
def SetColorTrig()
Definition: alice-desktop-1.3.pyw:2439
alice-desktop-1.MakeBodeScreen
def MakeBodeScreen()
Definition: alice-desktop-1.3-linux-test.pyw:14398
alice-desktop-1.BLoadAWGFiltB
def BLoadAWGFiltB()
Definition: alice-desktop-1.3-linux-test.pyw:21720
alice-desktop-1.onCanvasSnap
def onCanvasSnap(event)
Definition: alice-desktop-1.3-linux-test.pyw:9709
alice-desktop-1.CreateToolTip.unschedule
def unschedule(self)
Un-schedule Action.
Definition: alice-desktop-1.3-linux-test.pyw:906
alice-desktop-1.sel0
def sel0(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5838
alice-desktop-1.AWGBLoadWAV
def AWGBLoadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:11850
alice-desktop-1.SetIAPoss
def SetIAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2969
alice-desktop-1.OpenOtherTools
def OpenOtherTools()
Definition: alice-desktop-1.3-linux-test.pyw:23377
alice-desktop-1.AWGBMakeUGNoise
def AWGBMakeUGNoise()
Definition: alice-desktop-1.3-linux-test.pyw:12537
alice-desktop-1.onCanvasBodeClickScroll
def onCanvasBodeClickScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18023
alice-desktop-1.BSaveMuxData
def BSaveMuxData()
Save External Mux data to file.
Definition: alice-desktop-1.3-linux-test.pyw:2118
alice-desktop-1.onCanvasSASix
def onCanvasSASix(event)
Definition: alice-desktop-1.3-linux-test.pyw:17949
alice-desktop-1.onStopBodeScroll
def onStopBodeScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22342
alice-desktop-1.IACapZero
def IACapZero()
Definition: alice-desktop-1.3-linux-test.pyw:15540
alice-desktop-1.VAtoggle
def VAtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15886
alice-desktop-1.AWGBMakeFourier
def AWGBMakeFourier()
Definition: alice-desktop-1.3-linux-test.pyw:11916
alice-desktop-1.AWGAMakeTrapazoid
def AWGAMakeTrapazoid()
Definition: alice-desktop-1.3-linux-test.pyw:10922
alice-desktop-1.Blevel1BP
def Blevel1BP()
Definition: alice-desktop-1.3-linux-test.pyw:13359
alice-desktop-1.ReSetBIGO
def ReSetBIGO()
Definition: alice-desktop-1.3-linux-test.pyw:23369
alice-desktop-1.ETSUpdate
def ETSUpdate()
Definition: alice-desktop-1.3-linux-test.pyw:22738
alice-desktop-1.UpdateFreqTrace
def UpdateFreqTrace()
Definition: alice-desktop-1.3-linux-test.pyw:13458
alice-desktop-1.ReSetBGO
def ReSetBGO()
Definition: alice-desktop-1.3-linux-test.pyw:23353
alice-desktop-1.BlueNoise
def BlueNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10015
alice-desktop-1.SetMuxBPoss
def SetMuxBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2891
alice-desktop-1.shift_buffer
def shift_buffer(arr, num, fill_value=numpy.nan)
Function to left (-num) or right (+num) shift buffer and fill with a value returns same length buffer...
Definition: alice-desktop-1.3-linux-test.pyw:5000
alice-desktop-1.UpdatePhAAll
def UpdatePhAAll()
Definition: alice-desktop-1.3-linux-test.pyw:16130
alice-desktop-1.onCanvasBdThree
def onCanvasBdThree(event)
Definition: alice-desktop-1.3-linux-test.pyw:18138
alice-desktop-1.NqPCaresize
def NqPCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:15585
alice-desktop-1.BDBdiv2
def BDBdiv2()
Definition: alice-desktop-1.3-linux-test.pyw:13222
alice-desktop-1.Save_Cal_file
def Save_Cal_file()
Definition: alice-desktop-1.3-linux-test.pyw:20510
alice-desktop-1.MakeAWGWindow
def MakeAWGWindow()
Definition: alice-desktop-1.3-linux-test.pyw:18337
alice-desktop-1.SplitAWGAwaveform
def SplitAWGAwaveform()
Definition: alice-desktop-1.3-linux-test.pyw:10394
alice-desktop-1.BAWGBFreq
def BAWGBFreq(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11647
alice-desktop-1.onCanvasBdFour
def onCanvasBdFour(event)
Definition: alice-desktop-1.3-linux-test.pyw:18145
alice-desktop-1.UpdateTimeAll
def UpdateTimeAll()
Update Data, trace and time screen.
Definition: alice-desktop-1.3-linux-test.pyw:5992
alice-desktop-1.NiCCaresize
def NiCCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:15712
alice-desktop-1.CreateToolTip.configure
def configure(self, text)
Re Configure text string.
Definition: alice-desktop-1.3-linux-test.pyw:934
alice-desktop-1.CreateToolTip.enter
def enter(self, event=None)
Action when mouse enters.
Definition: alice-desktop-1.3-linux-test.pyw:895
alice-desktop-1.Analog_Phase_In
def Analog_Phase_In()
Definition: alice-desktop-1.3-linux-test.pyw:3769
alice-desktop-1.BAWGBOffset
def BAWGBOffset(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11609
alice-desktop-1.BHoldOff
def BHoldOff(event)
Set Hold off time from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2827
alice-desktop-1.BHistAsPercent
def BHistAsPercent()
Plot Histogram as Percent?
Definition: alice-desktop-1.3-linux-test.pyw:5353
alice-desktop-1.SetSampleRate
def SetSampleRate()
Definition: alice-desktop-1.3-linux-test.pyw:22285
alice-desktop-1.onCanvasSAEight
def onCanvasSAEight(event)
Definition: alice-desktop-1.3-linux-test.pyw:17963
alice-desktop-1.UpdateFreqScreen
def UpdateFreqScreen()
Definition: alice-desktop-1.3-linux-test.pyw:13462
alice-desktop-1.AWGAMakeHalfWaveSine
def AWGAMakeHalfWaveSine()
Definition: alice-desktop-1.3.pyw:11335
alice-desktop-1.DoFFT
def DoFFT()
Definition: alice-desktop-1.3-linux-test.pyw:13465
alice-desktop-1.onCanvasClickScroll
def onCanvasClickScroll(event)
Shift Time or vertical cursors if on or shift gated measurement cursors if enabled.
Definition: alice-desktop-1.3-linux-test.pyw:9113
alice-desktop-1.CreateToolTip.__init__
def __init__(self, widget, text='widget info')
create a tooltip for a given widget
Definition: alice-desktop-1.3-linux-test.pyw:884
alice-desktop-1.BAWGSync
def BAWGSync()
Definition: alice-desktop-1.3-linux-test.pyw:12790
alice-desktop-1.sel3
def sel3(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5937
alice-desktop-1.IACheckBox
def IACheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3365
alice-desktop-1.SetMuxAPoss
def SetMuxAPoss()
Analog Mux buttons.
Definition: alice-desktop-1.3-linux-test.pyw:2885
alice-desktop-1.IACaresize
def IACaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:15320
alice-desktop-1.Wrap
def Wrap(InArray, WrFactor)
Definition: alice-desktop-1.3-linux-test.pyw:10076
alice-desktop-1.SetScaleMuxA
def SetScaleMuxA()
Definition: alice-desktop-1.3-linux-test.pyw:2909
alice-desktop-1.MakeBodeWindow
def MakeBodeWindow()
Definition: alice-desktop-1.3-linux-test.pyw:19097
alice-desktop-1.BSaveChannelData
def BSaveChannelData()
Save selected scope time array data to file.
Definition: alice-desktop-1.3-linux-test.pyw:2132
alice-desktop-1.BShowCurvesAllBP
def BShowCurvesAllBP()
Definition: alice-desktop-1.3-linux-test.pyw:13416
alice-desktop-1.DestroyAD5626Screen
def DestroyAD5626Screen()
Definition: alice-desktop-1.3-linux-test.pyw:21217
alice-desktop-1.SetColorT4
def SetColorT4()
Definition: alice-desktop-1.3.pyw:2288
alice-desktop-1.DestroyBodeScreen
def DestroyBodeScreen()
Definition: alice-desktop-1.3-linux-test.pyw:19401
alice-desktop-1.TimeSeriesSingleTone
def TimeSeriesSingleTone(n, BinNum, Fsample, mag)
Definition: alice-desktop-1.3-linux-test.pyw:9989
alice-desktop-1.BAWGAAmpl
def BAWGAAmpl(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10143
alice-desktop-1.UpdateXYAll
def UpdateXYAll()
Update Data, trace and XY screen.
Definition: alice-desktop-1.3-linux-test.pyw:6007
alice-desktop-1.BAveragemode
def BAveragemode()
Definition: alice-desktop-1.3-linux-test.pyw:12867
alice-desktop-1.SettingsUpdate
def SettingsUpdate()
Definition: alice-desktop-1.3-linux-test.pyw:23140
alice-desktop-1.UpdateIATrace
def UpdateIATrace()
Definition: alice-desktop-1.3-linux-test.pyw:14734
alice-desktop-1.DestroyAWGScreen
def DestroyAWGScreen()
Definition: alice-desktop-1.3-linux-test.pyw:18737
alice-desktop-1.CreateToolTip.text
text
Definition: alice-desktop-1.3-linux-test.pyw:888
alice-desktop-1.XYcaresize
def XYcaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:19742
alice-desktop-1.UpdateNiCTrace
def UpdateNiCTrace()
Definition: alice-desktop-1.3-linux-test.pyw:15875
alice-desktop-1.UnitConvert
def UnitConvert(Value)
Definition: alice-desktop-1.3.pyw:23520
alice-desktop-1.BAWGAPhaseDelay
def BAWGAPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:10268
alice-desktop-1.MGLoad
def MGLoad()
Definition: alice-desktop-1.3-linux-test.pyw:22696
alice-desktop-1.BLoadAWGBFiltClip
def BLoadAWGBFiltClip()
Definition: alice-desktop-1.3-linux-test.pyw:2221
alice-desktop-1.DrawRes
def DrawRes(X, Y)
Definition: alice-desktop-1.3.pyw:23562
alice-desktop-1.BPeakholdmode
def BPeakholdmode()
Definition: alice-desktop-1.3-linux-test.pyw:12857
color-chooser-test.askcolor
def askcolor(text)
Definition: color-chooser-test.py:31
alice-desktop-1.PinkNoise
def PinkNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10000
alice-desktop-1.DestroyDigFiltScreen
def DestroyDigFiltScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21545
alice-desktop-1.onCanvasOne
def onCanvasOne(event)
Definition: alice-desktop-1.3-linux-test.pyw:9637
alice-desktop-1.Blevel1
def Blevel1()
Definition: alice-desktop-1.3-linux-test.pyw:13134
alice-desktop-1.MakeTimeTrace
def MakeTimeTrace()
Make the scope time traces.
Definition: alice-desktop-1.3-linux-test.pyw:6022
alice-desktop-1.CreateToolTip.wraplength
wraplength
Definition: alice-desktop-1.3-linux-test.pyw:886
alice-desktop-1.AWGAMakeImpulse
def AWGAMakeImpulse()
Definition: alice-desktop-1.3-linux-test.pyw:11190
alice-desktop-1.BRoll
def BRoll()
Toggel on/off Roll Sweep Mode.
Definition: alice-desktop-1.3-linux-test.pyw:3188
alice-desktop-1.SplitAWGBwaveform
def SplitAWGBwaveform()
Definition: alice-desktop-1.3-linux-test.pyw:11821
alice-desktop-1.SetXYIBPoss
def SetXYIBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2999
messagebox
alice-desktop-1.SetColorT6
def SetColorT6()
Definition: alice-desktop-1.3.pyw:2314
alice-desktop-1.Blevel2
def Blevel2()
Definition: alice-desktop-1.3-linux-test.pyw:13143
alice-desktop-1.OhmCheckBox
def OhmCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3391
alice-desktop-1.onAD5626Scroll
def onAD5626Scroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21213
alice-desktop-1.Analog_Freq_In
def Analog_Freq_In()
Main SA and Bode loop Read from the stream and store the data into the arrays.
Definition: alice-desktop-1.3-linux-test.pyw:5014
alice-desktop-1.MakeDigFiltWindow
def MakeDigFiltWindow()
Make screen for applying digital filters.
Definition: alice-desktop-1.3-linux-test.pyw:21322
alice-desktop-1.AWGBMakeSinc
def AWGBMakeSinc()
Definition: alice-desktop-1.3-linux-test.pyw:12061
alice-desktop-1.SetChopMuxMode
def SetChopMuxMode()
Definition: alice-desktop-1.3-linux-test.pyw:18970
alice-desktop-1.BLoadDFiltA
def BLoadDFiltA()
Definition: alice-desktop-1.3-linux-test.pyw:21551
alice-desktop-1.FindTriggerSample
def FindTriggerSample(TrgBuff)
Find the sample where trigger event happened.
Definition: alice-desktop-1.3-linux-test.pyw:5523
alice-desktop-1.onCanvasDownArrow
def onCanvasDownArrow(event)
Move Vertical cursors down 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9200
alice-desktop-1.CreateToolTip.leave
def leave(self, event=None)
Action when mouse leaves.
Definition: alice-desktop-1.3-linux-test.pyw:898
alice-desktop-1.TimeSeriesNoise
def TimeSeriesNoise(n, Fsample, mag, b=4)
Definition: alice-desktop-1.3-linux-test.pyw:9967
alice-desktop-1.onCanvasSpaceBar
def onCanvasSpaceBar(event)
Pause / start on space bar.
Definition: alice-desktop-1.3-linux-test.pyw:9326
alice-desktop-1.MakeNyquistPlot
def MakeNyquistPlot()
Definition: alice-desktop-1.3-linux-test.pyw:15553
alice-desktop-1.onRetDigFiltA
def onRetDigFiltA(event)
Definition: alice-desktop-1.3-linux-test.pyw:21495
alice-desktop-1.SetScaleIA
def SetScaleIA()
Definition: alice-desktop-1.3-linux-test.pyw:9054
alice-desktop-1.FindRisingEdge
def FindRisingEdge(Trace1, Trace2)
Routine to find rising edge of traces.
Definition: alice-desktop-1.3-linux-test.pyw:5361
alice-desktop-1.MakeBoardScreen
def MakeBoardScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22032
alice-desktop-1.AWGAMakeAMSine
def AWGAMakeAMSine()
Definition: alice-desktop-1.3-linux-test.pyw:10653
alice-desktop-1.AWGAMakePWMSine
def AWGAMakePWMSine()
Definition: alice-desktop-1.3-linux-test.pyw:10727
alice-desktop-1.SetAD9833
def SetAD9833(temp)
Definition: alice-desktop-1.3-linux-test.pyw:20625
alice-desktop-1.MakeResDivWindow
def MakeResDivWindow()
Definition: alice-desktop-1.3.pyw:23598
alice-desktop-1.DestroyMuxScreen
def DestroyMuxScreen()
Definition: alice-desktop-1.3-linux-test.pyw:19007
alice-desktop-1.onCanvasShowdBcur
def onCanvasShowdBcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:17997
alice-desktop-1.BuildAWGBoxCarA
def BuildAWGBoxCarA()
Definition: alice-desktop-1.3-linux-test.pyw:21634
alice-desktop-1.AWGBNumCycles
def AWGBNumCycles()
Definition: alice-desktop-1.3-linux-test.pyw:11556
alice-desktop-1.SetXYIAPoss
def SetXYIAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2993
alice-desktop-1.BSendGS
def BSendGS()
Definition: alice-desktop-1.3-linux-test.pyw:21069
alice-desktop-1.onTextKey
def onTextKey(event)
Definition: alice-desktop-1.3-linux-test.pyw:18275
alice-desktop-1.SetColorTR6
def SetColorTR6()
Definition: alice-desktop-1.3.pyw:2397
alice-desktop-1.Bnot
def Bnot()
Definition: alice-desktop-1.3-linux-test.pyw:12830
alice-desktop-1.BSetMarkerLocation
def BSetMarkerLocation()
Ask user for new Marker text location on screen.
Definition: alice-desktop-1.3-linux-test.pyw:2718
alice-desktop-1.MakePhAWindow
def MakePhAWindow()
Definition: alice-desktop-1.3-linux-test.pyw:15927
alice-desktop-1.onCanvasTrising
def onCanvasTrising(event)
Definition: alice-desktop-1.3-linux-test.pyw:9699
alice-desktop-1.BLoadConfigBP
def BLoadConfigBP()
Load confirfuration from Bode window button.
Definition: alice-desktop-1.3-linux-test.pyw:1907
alice-desktop-1.AWGBLoadCSV
def AWGBLoadCSV()
Definition: alice-desktop-1.3-linux-test.pyw:11783
alice-desktop-1.onAWGBscroll
def onAWGBscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18217
alice-desktop-1.TraceSelectADC_Mux
def TraceSelectADC_Mux()
Definition: alice-desktop-1.3-linux-test.pyw:22430
alice-desktop-1.SetColorT3
def SetColorT3()
Definition: alice-desktop-1.3.pyw:2273
alice-desktop-1.onCanvasTfalling
def onCanvasTfalling(event)
Definition: alice-desktop-1.3-linux-test.pyw:9704
alice-desktop-1.CALCFFTwindowshape
def CALCFFTwindowshape()
Definition: alice-desktop-1.3-linux-test.pyw:17652
alice-desktop-1.ETSCheckBox
def ETSCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3404
alice-desktop-1.SetColorText
def SetColorText()
Definition: alice-desktop-1.3.pyw:2429
alice-desktop-1.onAWGFiltAScroll
def onAWGFiltAScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21630
alice-desktop-1.AWGAMakeUGNoise
def AWGAMakeUGNoise()
Definition: alice-desktop-1.3-linux-test.pyw:11291
alice-desktop-1.MakeIAScreen
def MakeIAScreen()
Draw the impedance Analyzer screen.
Definition: alice-desktop-1.3-linux-test.pyw:14913
alice-desktop-1.onTextScroll
def onTextScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18225
alice-desktop-1.AWGAMakeFourier
def AWGAMakeFourier()
Definition: alice-desktop-1.3-linux-test.pyw:10768
alice-desktop-1.AWGAReadFile
def AWGAReadFile()
Definition: alice-desktop-1.3-linux-test.pyw:10346
alice-desktop-1.BSaveScreenXY
def BSaveScreenXY()
Save XY canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2052
alice-desktop-1.UpdateBodeScreen
def UpdateBodeScreen()
Definition: alice-desktop-1.3-linux-test.pyw:13442
alice-desktop-1.BAWGADutyCycle
def BAWGADutyCycle(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10296
alice-desktop-1.MakeCommandScreen
def MakeCommandScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21809
alice-desktop-1.BSaveToClipBoard
def BSaveToClipBoard(TempBuffer)
Definition: alice-desktop-1.3-linux-test.pyw:2184
alice-desktop-1.BAbout
def BAbout()
Show info on software / firmware / hardware.
Definition: alice-desktop-1.3-linux-test.pyw:2267
alice-desktop-1.DestroyDigScreen
def DestroyDigScreen()
Distroy the Digital I/O screen.
Definition: alice-desktop-1.3-linux-test.pyw:5642
alice-desktop-1.BCHBIlevel
def BCHBIlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3265
alice-desktop-1.BUserFFTwindow
def BUserFFTwindow()
Definition: alice-desktop-1.3-linux-test.pyw:17741
alice-desktop-1.Write_WAV
def Write_WAV(data, repeat, filename)
Definition: alice-desktop-1.3-linux-test.pyw:10107
alice-desktop-1.SetScaleMuxC
def SetScaleMuxC()
Definition: alice-desktop-1.3-linux-test.pyw:2933
alice-desktop-1.SetMuxDPoss
def SetMuxDPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2903
alice-desktop-1.BSaveScreen
def BSaveScreen()
Save scope canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2033
alice-desktop-1.TimeCheckBox
def TimeCheckBox()
set check box colors
Definition: alice-desktop-1.3-linux-test.pyw:3324
alice-desktop-1.BPower
def BPower()
Toggel on/off analog power.
Definition: alice-desktop-1.3-linux-test.pyw:3174
alice-desktop-1.CreateToolTip.showtip
def showtip(self, event=None)
Display Tip Text.
Definition: alice-desktop-1.3-linux-test.pyw:912
alice-desktop-1.BDBdiv1BP
def BDBdiv1BP()
Definition: alice-desktop-1.3-linux-test.pyw:13395
alice-desktop-1.BodeCheckBox
def BodeCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3351
alice-desktop-1.MakeXYWindow
def MakeXYWindow()
Definition: alice-desktop-1.3-linux-test.pyw:19758
alice-desktop-1.AWGBConfigMath
def AWGBConfigMath()
Definition: alice-desktop-1.3-linux-test.pyw:11904
alice-desktop-1.BLoadConfigIA
def BLoadConfigIA()
Load confirfuration from IA window button.
Definition: alice-desktop-1.3-linux-test.pyw:1895
alice-desktop-1.BUserCustomPlotText
def BUserCustomPlotText()
Ask user to enter custom plot label string.
Definition: alice-desktop-1.3-linux-test.pyw:2464
alice-desktop-1.ReSetAIGO
def ReSetAIGO()
Definition: alice-desktop-1.3-linux-test.pyw:23361
alice-desktop-1.SetColorT1
def SetColorT1()
Definition: alice-desktop-1.3.pyw:2243
alice-desktop-1.BSaveScreenSA
def BSaveScreenSA()
Definition: alice-desktop-1.3-linux-test.pyw:12813
alice-desktop-1.RDSetBGO
def RDSetBGO()
Definition: alice-desktop-1.3.pyw:23586
alice-desktop-1.AWGAMakeFullWaveSine
def AWGAMakeFullWaveSine()
Definition: alice-desktop-1.3.pyw:11273
alice-desktop-1.BShowCurvesAllSA
def BShowCurvesAllSA()
Definition: alice-desktop-1.3-linux-test.pyw:12833
alice-desktop-1.donothing
def donothing()
Nop.
Definition: alice-desktop-1.3-linux-test.pyw:2728
alice-desktop-1.SettingsTextKey
def SettingsTextKey(event)
Definition: alice-desktop-1.3-linux-test.pyw:22826
alice-desktop-1.BuildAWGBoxCarB
def BuildAWGBoxCarB()
Definition: alice-desktop-1.3-linux-test.pyw:21660
alice-desktop-1.onCanvasShowVcur
def onCanvasShowVcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:9729
alice-desktop-1.VioletNoise
def VioletNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10047
alice-desktop-1.CheckMathYString
def CheckMathYString()
Check Y Math String for syntac errors.
Definition: alice-desktop-1.3-linux-test.pyw:2677
alice-desktop-1.onCanvasSASeven
def onCanvasSASeven(event)
Definition: alice-desktop-1.3-linux-test.pyw:17956
alice-desktop-1.MakeTimeScreen
def MakeTimeScreen()
Update the time screen with traces and text
Definition: alice-desktop-1.3-linux-test.pyw:7377
alice-desktop-1.BStopBP
def BStopBP()
Definition: alice-desktop-1.3-linux-test.pyw:13337
alice-desktop-1.Settingsscroll
def Settingsscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22822
alice-desktop-1.onCanvasSAReset
def onCanvasSAReset(event)
Definition: alice-desktop-1.3-linux-test.pyw:17984
alice-desktop-1.FourierSawTooth
def FourierSawTooth(Length, NumTerms, Ampl)
Definition: alice-desktop-1.3.pyw:10562
alice-desktop-1.BSaveDataIA
def BSaveDataIA()
Definition: alice-desktop-1.3-linux-test.pyw:13037
alice-desktop-1.UpdateXYTrace
def UpdateXYTrace()
Update XY trace and screen.
Definition: alice-desktop-1.3-linux-test.pyw:6012
alice-desktop-1.BDBdiv2BP
def BDBdiv2BP()
Definition: alice-desktop-1.3-linux-test.pyw:13405
alice-desktop-1.BShowCurvesNoneBP
def BShowCurvesNoneBP()
Definition: alice-desktop-1.3-linux-test.pyw:13423
alice-desktop-1.BStart
def BStart()
Start aquaring scope time data.
Definition: alice-desktop-1.3-linux-test.pyw:3031
alice-desktop-1.SetVAPoss
def SetVAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2957
alice-desktop-1.sel2
def sel2(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5904
alice-desktop-1.ResetColors
def ResetColors()
Colors that can be modified Use function to reset to "factory" colors.
Definition: alice-desktop-1.3.pyw:154
alice-desktop-1.DestroySettings
def DestroySettings()
Definition: alice-desktop-1.3-linux-test.pyw:23324
alice-desktop-1.BodeCaresize
def BodeCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:19023
alice-desktop-1.SetColorGrid
def SetColorGrid()
Definition: alice-desktop-1.3.pyw:2419
alice-desktop-1.onAWGAscroll
def onAWGAscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18209
alice-desktop-1.BuildRejectFilter
def BuildRejectFilter(Order, Freject, Fsample)
Definition: alice-desktop-1.3-linux-test.pyw:21761
alice-desktop-1.AWGAConfigMath
def AWGAConfigMath()
Definition: alice-desktop-1.3-linux-test.pyw:10503
alice-desktop-1.FreqCaresize
def FreqCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:19411
alice-desktop-1.Ohm_Analog_In
def Ohm_Analog_In()
Ohmmeter loop.
Definition: alice-desktop-1.3-linux-test.pyw:3578
ttk
alice-desktop-1.AWGBMakeBodeSine
def AWGBMakeBodeSine()
Definition: alice-desktop-1.3-linux-test.pyw:11951
alice-desktop-1.BHozPoss
def BHozPoss(event)
Definition: alice-desktop-1.3-linux-test.pyw:2838
alice-desktop-1.BSetFmin
def BSetFmin()
Definition: alice-desktop-1.3-linux-test.pyw:23337
alice-desktop-1.CreateToolTip
Tool Tip Ballon help stuff.
Definition: alice-desktop-1.3-linux-test.pyw:882
alice-desktop-1.MakeDigPotWindow
def MakeDigPotWindow()
set up controls for single, dual or quad, digital pots
Definition: alice-desktop-1.3-linux-test.pyw:21012
alice-desktop-1.RDbutton
def RDbutton()
Definition: alice-desktop-1.3.pyw:23534
alice-desktop-1.Bsamples1
def Bsamples1()
Definition: alice-desktop-1.3-linux-test.pyw:13170
alice-desktop-1.BLoadCal
def BLoadCal()
Load gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3-linux-test.pyw:2410
alice-desktop-1.DestroyResDivScreen
def DestroyResDivScreen()
Definition: alice-desktop-1.3.pyw:23679
alice-desktop-1.Cal_trace_scalars
def Cal_trace_scalars(SampleStart, SampleEnd)
Definition: alice-desktop-1.3-linux-test.pyw:4909
alice-desktop-1.SetXYScaleB
def SetXYScaleB()
Definition: alice-desktop-1.3-linux-test.pyw:9097
alice-desktop-1.VABtoggle
def VABtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15894
alice-desktop-1.BAWGAShape
def BAWGAShape()
Definition: alice-desktop-1.3-linux-test.pyw:10315
alice-desktop-1.ConnectDevice
def ConnectDevice()
Definition: alice-desktop-1.3-linux-test.pyw:22087
alice-desktop-1.DestroyGenericSerialScreen
def DestroyGenericSerialScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21315
alice-desktop-1.BLoadAWGAFiltClip
def BLoadAWGAFiltClip()
Definition: alice-desktop-1.3-linux-test.pyw:2215
alice-desktop-1.BAWGEnab
def BAWGEnab()
Definition: alice-desktop-1.3-linux-test.pyw:12769
alice-desktop-1.MakeDA1Window
def MakeDA1Window()
Make window to control PMOD DA1 board.
Definition: alice-desktop-1.3-linux-test.pyw:20862
alice-desktop-1.CreateToolTip.schedule
def schedule(self)
Sehedule Action.
Definition: alice-desktop-1.3-linux-test.pyw:902
alice-desktop-1.onTextKeyAWG
def onTextKeyAWG(event)
Definition: alice-desktop-1.3-linux-test.pyw:18270
alice-desktop-1.BStartBP
def BStartBP()
Definition: alice-desktop-1.3-linux-test.pyw:13233
alice-desktop-1.onStopfreqScroll
def onStopfreqScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22322
alice-desktop-1.BCSVfile
def BCSVfile()
Definition: alice-desktop-1.3-linux-test.pyw:12963
alice-desktop-1.SetScaleA
def SetScaleA()
Definition: alice-desktop-1.3-linux-test.pyw:9042
alice-desktop-1.BSaveScreenIA
def BSaveScreenIA()
Save IA canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2071
alice-desktop-1.onCanvasSAFour
def onCanvasSAFour(event)
Definition: alice-desktop-1.3-linux-test.pyw:17935
alice-desktop-1.MakeSettingsMenu
def MakeSettingsMenu()
Definition: alice-desktop-1.3-linux-test.pyw:22830
alice-desktop-1.BUserAMeas
def BUserAMeas()
Ask user for channel A Measurement Label and Formula.
Definition: alice-desktop-1.3-linux-test.pyw:2429
alice-desktop-1.UpdateXYScreen
def UpdateXYScreen()
Update XY screen with trace and text.
Definition: alice-desktop-1.3-linux-test.pyw:6017
alice-desktop-1.onCanvasBodeRightClick
def onCanvasBodeRightClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:18011
alice-desktop-1.BSendMG
def BSendMG()
Send serial data to DDS board.
Definition: alice-desktop-1.3-linux-test.pyw:20655
alice-desktop-1.onCanvasUpArrow
def onCanvasUpArrow(event)
Move Vertical cursors up 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9158
alice-desktop-1.AWGBWriteFile
def AWGBWriteFile()
Definition: alice-desktop-1.3-linux-test.pyw:11876
alice-desktop-1.BSavePhAData
def BSavePhAData()
Definition: alice-desktop-1.3-linux-test.pyw:16992
alice-desktop-1.UpdateBodeAll
def UpdateBodeAll()
Definition: alice-desktop-1.3-linux-test.pyw:13430
alice-desktop-1.BUserBMeas
def BUserBMeas()
Ask user for channel B Measurement Label and Formula.
Definition: alice-desktop-1.3-linux-test.pyw:2446
alice-desktop-1.Blevel4
def Blevel4()
Definition: alice-desktop-1.3-linux-test.pyw:13161
alice-desktop-1.BOffsetA
def BOffsetA(event)
Definition: alice-desktop-1.3-linux-test.pyw:3276
alice-desktop-1.DestroyNiCScreen
def DestroyNiCScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15705
alice-desktop-1.BTime
def BTime()
Set Hor time scale from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:3199
alice-desktop-1.onCanvasSAAverage
def onCanvasSAAverage(event)
Definition: alice-desktop-1.3-linux-test.pyw:17987
alice-desktop-1.AWGAMakeBodeSine
def AWGAMakeBodeSine()
Definition: alice-desktop-1.3-linux-test.pyw:10515
alice-desktop-1.DestroyColorScreen
def DestroyColorScreen()
Definition: alice-desktop-1.3.pyw:2192
alice-desktop-1.onCanvasSANormal
def onCanvasSANormal(event)
Definition: alice-desktop-1.3-linux-test.pyw:17978
alice-desktop-1.BCHAIlevel
def BCHAIlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3243
alice-desktop-1.onCanvasFreqClickScroll
def onCanvasFreqClickScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:17783
alice-desktop-1.CreateToolTip.hidetip
def hidetip(self)
Hide Tip Action.
Definition: alice-desktop-1.3-linux-test.pyw:928
alice-desktop-1.BStop
def BStop()
Stop (pause) scope tool.
Definition: alice-desktop-1.3-linux-test.pyw:3141
alice-desktop-1.DestroyDA1Screen
def DestroyDA1Screen()
Destroy PMOD DA1 screen.
Definition: alice-desktop-1.3-linux-test.pyw:20913
alice-desktop-1.onCanvasEight
def onCanvasEight(event)
Definition: alice-desktop-1.3-linux-test.pyw:9684
alice-desktop-1.onCanvasFreqRightClick
def onCanvasFreqRightClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:17772
alice-desktop-1.onCanvasSAOne
def onCanvasSAOne(event)
Definition: alice-desktop-1.3-linux-test.pyw:17914
alice-desktop-1.SetColorZLine
def SetColorZLine()
Definition: alice-desktop-1.3.pyw:2450
alice-desktop-1.BAWGBAmpl
def BAWGBAmpl(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11570
alice-desktop-1.BAWGFiltAMath
def BAWGFiltAMath()
Definition: alice-desktop-1.3-linux-test.pyw:21703
alice-desktop-1.SetScaleIB
def SetScaleIB()
Definition: alice-desktop-1.3-linux-test.pyw:9078
alice-desktop-1.AWGAMakeUpDownRamp
def AWGAMakeUpDownRamp()
Definition: alice-desktop-1.3-linux-test.pyw:11122
alice-desktop-1.BgColor
def BgColor()
Toggle the Background and text colors based on ColorMode.
Definition: alice-desktop-1.3-linux-test.pyw:1998
alice-desktop-1.onFminScroll
def onFminScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22710